Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. try{
  2. String connectionURL = "jdbc:mysql://localhost/employees";
  3.  
  4. Connection connection = null;
  5. Statement statement = null;
  6. ResultSet resultSet = null;
  7.  
  8. Class.forName("com.mysql.jdbc.Driver").newInstance();
  9. connection = DriverManager.getConnection(connectionURL, "root", "");
  10. statement = connection.createStatement();
  11.  
  12. if(!connection.isClosed()){
  13. out.println("Successfully connected to MySQL server" + "<br/>");
  14. }
  15.  
  16. } catch(Exception ex){
  17.  
  18. out.println("Unable to connect to database: "+ ex);
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement