Guest User

Untitled

a guest
Sep 2nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. Couldn't make mysql connector j work
  2. import java.sql.*;
  3.  
  4. public class JdbcExample1 {
  5.  
  6. public static void main(String args[]) {
  7. Connection con = null;
  8.  
  9. try {
  10. Class.forName("com.mysql.jdbc.Driver").newInstance();
  11. con = DriverManager.getConnection("jdbc:mysql:///test", "root", "secret");
  12.  
  13. if(!con.isClosed())
  14. System.out.println("Successfully connected to MySQL server...");
  15.  
  16. } catch(Exception e) {
  17. System.err.println("Exception: " + e.getMessage());
  18. } finally {
  19. try {
  20. if(con != null)
  21. con.close();
  22. } catch(SQLException e) {}
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment