Advertisement
Guest User

Untitled

a guest
May 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.49 KB | None | 0 0
  1.     try {
  2.       Class.forName("com.mysql.jdbc.Driver");
  3.       con = DriverManager.getConnection("jdbc:mysql:/127.0.0.1:3306/MyDB",
  4.         "USER", "PW");
  5.  
  6.       if(!con.isClosed())
  7.         System.out.println("Successfully connected to " +
  8.           "MySQL server using TCP/IP...");
  9.  
  10.     } catch(Exception e) {
  11.       System.err.println("Exception: " + e.getMessage());
  12.     } finally {
  13.       try {
  14.         if(con != null)
  15.           con.close();
  16.       } catch(SQLException e) {}
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement