Advertisement
Guest User

Untitled

a guest
May 17th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1.         String url = "jdbc:mysql://localhost:3306/test"; // test is the db name
  2.         String user = "root";
  3.         String password = "root";
  4.         Connection conn = null;
  5.         PreparedStatement stt;
  6.         ResultSet rs;
  7.        
  8.         try{
  9.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  10.             conn = DriverManager.getConnection(url, user, password);
  11.         }catch(Exception e){
  12.             JOptionPane.showMessageDialog(null, "Error in establishing connection with database");
  13.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement