Advertisement
brixium

MySQL JDBC connection

Nov 29th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. try
  2. {
  3.   Class.forName("com.mysql.jdbc.Driver").newInstance();
  4.   String url = "jdbc:mysql://HOST/DATABASE";
  5.   conn = DriverManager.getConnection(url, "username", "password");
  6.   doTests();
  7.   conn.close();
  8. }
  9. catch (ClassNotFoundException ex) {System.err.println(ex.getMessage());}
  10. catch (IllegalAccessException ex) {System.err.println(ex.getMessage());}
  11. catch (InstantiationException ex) {System.err.println(ex.getMessage());}
  12. catch (SQLException ex)           {System.err.println(ex.getMessage());}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement