Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public static void main(String[] args) throws SQLException {
  2.  
  3.  
  4. try {
  5.  
  6. DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
  7. } catch(Exception e) { System.out.println("Could not connect. Errormessage: " + e);}
  8. try {
  9.  
  10. Connection con =
  11. DriverManager.getConnection
  12. ("jdbc:sqlserver://localhost:1433;" + "databaseName=Inlämningsuppgifter;user=sa;password=test123;");
  13. if (con == null)
  14. System.out.println("No driver found");
  15. else
  16. System.out.println("Connected to database");
  17.  
  18.  
  19.  
  20. }
  21. catch(Exception e) { System.out.println("Error message: " + e);
  22.  
  23. }
  24.  
  25. }
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement