Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. private static final String USER = "user";
  2. private static final String PASS = "pass";
  3. private static final String URL = "jdbc:mysql://node30220-learning.j.dnr.kz/user";
  4.  
  5. public static void main(String[] args) {
  6. Connection conn = null;
  7. Statement stmt = null;
  8. try {
  9. Class.forName("com.mysql.jdbc.Driver");
  10. System.out.println("Connecting to database...");
  11. conn = DriverManager.getConnection(URL, USER, PASS);
  12. stmt = conn.createStatement();
  13. String sql;
  14. sql = "SELECT * FROM DUAL";
  15. ResultSet rs = stmt.executeQuery(sql);
  16. while (rs.next()) {
  17.  
  18. }
  19. rs.close();
  20. stmt.close();
  21. conn.close();
  22. } catch (Exception e) {
  23. e.printStackTrace();
  24. }
  25. System.out.println("Goodbye!");
  26. }
  27.  
  28. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement