当前位置: 代码迷 >> Java Web开发 >> jdbc.CommunicationsException: Communications link failure
  详细解决方案

jdbc.CommunicationsException: Communications link failure

热度:600   发布时间:2016-04-17 01:21:18.0
郁闷,把时间调后一天程序出现异常
测试程序的时候,我把当前时间往后加了一天,mysql还是正常启动的,tomcat也正常运行,但是当我重新登录的时候,会报一下错误: 
Java code
2008-12-07 22:39:07,791 ERROR [org.hibernate.transaction.JDBCTransaction] - JDBC begin failed   com.mysql.jdbc.CommunicationsException: Communications link failure   Last packet sent to the server was 0 ms ago.       at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1070)       at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)       at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871) 

Java code
Caused by: java.net.SocketException: Software caused connection abort: recv failed    at java.net.SocketInputStream.socketRead0(Native Method)    at java.net.SocketInputStream.read(Unknown Source)    at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113)    at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160)    at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188)    at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2428)    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882)

不调时间一切都正常啊,这是怎么回事?我在网上查说是socket链接没有关闭,程序中没有用啊,疑惑中。

------解决方案--------------------
可能是mysql版本的一个bug.
试试5.0.18

http://lists.mysql.com/java/8667
I reinstalled msyql-5.0.18, after that the problem disappear. I think that is a bug in mysql 5.0.16.

重新安装mysql, 新版本. 


另外, 学会用google, 那里可以给你很多非常多太多的答案!!!
------解决方案--------------------
你和时间和数据库服务器时间不一致吧?

是不是你数据库放在别的电脑上?
  相关解决方案