Advertisement
Guest User

Untitled

a guest
Mar 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. String url = "jdbc:mysql://localhost:3306/javabase";
  2. String username = "java";
  3. String password = "password";
  4.  
  5. System.out.println("Connecting database...");
  6.  
  7. try (Connection connection = DriverManager.getConnection(url, username, password)) {
  8. System.out.println("Database connected!");
  9. } catch (SQLException e) {
  10. throw new IllegalStateException("Cannot connect the database!", e);
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement