Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public static void main(String[] args) throws SQLException, IOException, ClassNotFoundException {
  2.  
  3. String dbURl = "jdbc:sqlserver://localhost:1433;DatabaseName=db";
  4. String userName = "u";
  5. String password = "P";
  6. new sam(dbURl, userName, password).createSQLFile();
  7.  
  8. public class sam {
  9. String userName;
  10. String dbURL;
  11. String password;
  12.  
  13. public sam(String dbURL, String userName, String password) {
  14. this.dbURL = dbURL;
  15. this.userName = userName;
  16. this.password = password;
  17. }
  18.  
  19. public void createSQLFile() throws IOException, SQLException, ClassNotFoundException {
  20. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  21. Connection con = DriverManager.getConnection(dbURL, userName, password);
  22. Statement statement = con.createStatement();
  23. String queryString = "Select object_definition(object_id) from sys.objects where type = 'P'";
  24. ResultSet rs = statement.executeQuery(queryString);
  25. while (rs.next()) {
  26. System.out.println(rs.getString(1));
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement