Advertisement
Guest User

Untitled

a guest
Feb 10th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. public static Connection ConnectDB() {
  2.  
  3. try {
  4. DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
  5. Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;user=sa;password=secret");
  6. System.out.println("Connected");
  7. return conn;
  8. } catch (Exception e) {
  9. System.err.println(e.getMessage());
  10. e.printStackTrace();
  11. System.out.println("Database connection error.");
  12. return null;
  13. }
  14. }
  15.  
  16. String dbURL = "jdbc:sqlserver://localhost\sqlexpress;user=sa;password=secret";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement