com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

来源:互联网 发布:陌生人社交软件 编辑:程序博客网 时间:2024/05/21 17:00

错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet successfully received from the server was 40,472 milliseconds ago.  The last packet sent successfully to the server was 2 milliseconds ago.    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)····················Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3011)    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3469)    ... 121 more

原因是:mysql配置文件中添加了一句:
修改MySQL配置文件/etc/my.cnf,设置成 wait_timeout=5

注意:这里的时间单位是5s,而默认的是8个小时才会过期,所以会报上面的错误,改大一点就可以了或者干脆删掉使用默认的。

阅读全文
0 0
原创粉丝点击