简体   繁体   English

错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败

[英]Error : com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

ERROR MESSAGE in SERVER 服务器中的错误消息

    [2019-01-07 09:44:02] ERROR 
    :com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications 
    link failure
    [2019-01-07 09:44:02]
    [2019-01-07 09:44:02] The last packet sent successfully to the server was 0 
    milliseconds ago. The driver has not received any packets from the server.

But testing in local.. No problem.. No Error message.. 但是在本地测试..没问题..没有错误信息..

  1. Commit libraries.. 提交库..

     mysql-connector-java-5.1.47-bin.jar mysql-connector-java-5.1.47.jar 
  2. JDBC URL ALTER JDBC URL更改

     jdbc:mysql://IP:3306/ID -> jdbc:mysql://IP:3306/ID?autoReconnect=true 

    Changed Error Message.. 更改错误消息

     [2019-01-07 11:04:32] Error : com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. 

ControlDAO.java ControlDAO.java

private final static String DRIVER = "com.mysql.jdbc.Driver";
private final static String URL = 
"jdbc:mysql://IP:3306/ID?autoReconnect=true;

public static void CsNumberCheck(String s) { 
    try {           
        Class.forName(DRIVER);

        conn = DriverManager.getConnection(URL, "ID", "PW");
        System.out.println(conn);

        stat = conn.createStatement();

        int result = 0;

        sql = Query;

        rs = stat.executeQuery(sql);

        while ( rs.next() ) {
            result = rs.getInt(1);
        }

        rs.close();
        stat.close();

        System.out.println(result);

        CsNumberResult(result, OrangeEmail);
    }
    catch (ClassNotFoundException e) {
        System.out.println("Driver Loading Failed..");
    }
    catch (SQLException e) {
        System.out.println("Error : " + e);
    }
}

Socket.java Socket.java

     ControlDAO.CsNumberCheck(s);
  • But nothing result about "Sysout", Only Error Message.... 但是没有结果关于“ Sysout”,只有错误消息。

Check your windows services to see if your MySQL server is running. 检查Windows服务以查看MySQL服务器是否正在运行。 That might be a probable cause. 那可能是原因。 If it's not, start it and try to reconnect. 如果不是,请启动它并尝试重新连接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败? - com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure? com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure AWS RDS连接数据库错误:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - AWS RDS connection database error : com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 出现错误com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - Getting Error com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败和BeanEntityManager错误 - com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure AND BeanEntityManager error MySQL:间歇性com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - MySQL: Intermittant com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure eclipe:间歇性com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - eclipe: Intermittent com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure “com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败”到远程数据库 - “com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure” to remote database com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - 由:java.net.UnknownHostException:null:未知错误 - com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure - Caused by: java.net.UnknownHostException: null: unknown error Travis CLI 上的 Spring Boot 测试失败,出现异常:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链接失败 - Spring Boot Test Fails on Travis CLI with an exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM