Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws SQLException, IOException, ClassNotFoundException {
- String dbURl = "jdbc:sqlserver://localhost:1433;DatabaseName=db";
- String userName = "u";
- String password = "P";
- new sam(dbURl, userName, password).createSQLFile();
- public class sam {
- String userName;
- String dbURL;
- String password;
- public sam(String dbURL, String userName, String password) {
- this.dbURL = dbURL;
- this.userName = userName;
- this.password = password;
- }
- public void createSQLFile() throws IOException, SQLException, ClassNotFoundException {
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- Connection con = DriverManager.getConnection(dbURL, userName, password);
- Statement statement = con.createStatement();
- String queryString = "Select object_definition(object_id) from sys.objects where type = 'P'";
- ResultSet rs = statement.executeQuery(queryString);
- while (rs.next()) {
- System.out.println(rs.getString(1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement