ibatis + glassfish:com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链路故障

时间:2010-07-30 09:29:09

标签: mysql glassfish ibatis

我随机收到错误:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通讯链接失败

有人有想法吗?

ERROR: java.sql.Connection - Error calling Connection.setAutoCommit:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 129,064 milliseconds ago.  The last packet sent successfully to the server was 0 milliseconds ago.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:409)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1118)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3055)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2941)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3489)

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:2502)
    at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2952)
    ... 83 more

1 个答案:

答案 0 :(得分:0)

MySQL服务器默认不侦听TCP端口3306。要允许(远程)TCP连接,请在/etc/mysql/my.cnf中注释以下行:

skip-networking