Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. try {
  2. // The newInstance() call is a work around for some
  3. // broken Java implementations
  4.  
  5. Class.forName("com.mysql.cj.jdbc.Driver");
  6. } catch (Exception ex) {
  7. // handle the error
  8. }
  9.  
  10. //Class.forName("com.mysql.cj.jdbc.Driver").newInstance();
  11. Connection conn = null;
  12.  
  13. try {
  14. conn =
  15. DriverManager.getConnection("jdbc:mysql://localhost/pippo?" +
  16. "user=root&password=password");
  17.  
  18. // Do something with the Connection
  19.  
  20.  
  21. } catch (SQLException ex) {
  22. // handle any errors
  23. System.out.println("SQLException: " + ex.getMessage());
  24. System.out.println("SQLState: " + ex.getSQLState());
  25. System.out.println("VendorError: " + ex.getErrorCode());
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement