日期:2014-05-16  浏览次数:20832 次

高手们..送分了~~!要详细回答
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: Connection reset

STACKTRACE:

java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
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:1910)
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:501)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:971)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.cdjj.wangcong.unit.BaseDao.getConnection(BaseDao.java:39)
at com.cdjj.wangcong.unit.BaseDao.executeNonQuery(BaseDao.java:76)
at com.cdjj.wangcong.model.UserInfoModel.addUser(UserInfoModel.java:18)
at com.cdjj.wangcong.test.UserInfoTest.main(UserInfoTest.java:12)


** END NESTED EXCEPTION **



Last packet sent to the server was 100 ms ago.
at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:569)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:971)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2644)
at com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.cdjj.wangcong.unit.BaseDao.getConnection(BaseDao.java:39)
at com.cdjj.wangcong.unit.BaseDao.executeNonQuery(BaseDao.java:76)
at com.cdjj.wangcong.model.UserInfoModel.addUser(UserInfoModel.java:18)
at com.cdjj.wangcong.test.UserInfoTest.main(UserInfoTest.java:12)
Exception in thread "main" java.lang.NullPointerException
at com.cdjj.wangcong.unit.BaseDao.executeNonQuery(BaseDao.java:80)
at com.cdjj.wangcong.model.UserInfoModel.addUser(UserInfoModel.java:18)
at com.cdjj.wangcong.test.UserInfoTest.main(UserInfoTest.java:12)
请问这个异常怎么解决?


------解决方案--------------------
贴出你MYSQL错误日志中的内容。
------解决方案--------------------
从调用栈来看,可能是客户端连接长时间不活动,被reset了。
建议:获取用户连接后,执行下述两个语句:
set wait_timeout=1073742824
set interactive_timeout=1073742824
以保持长连接。

------解决方案--------------------
有可能以下原因所致:
1. 网络不稳定。
2,MYSQL 漏洞。