Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final String USER = "user";
- private static final String PASS = "pass";
- private static final String URL = "jdbc:mysql://node30220-learning.j.dnr.kz/user";
- public static void main(String[] args) {
- Connection conn = null;
- Statement stmt = null;
- try {
- Class.forName("com.mysql.jdbc.Driver");
- System.out.println("Connecting to database...");
- conn = DriverManager.getConnection(URL, USER, PASS);
- stmt = conn.createStatement();
- String sql;
- sql = "SELECT * FROM DUAL";
- ResultSet rs = stmt.executeQuery(sql);
- while (rs.next()) {
- }
- rs.close();
- stmt.close();
- conn.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- System.out.println("Goodbye!");
- }
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement