feng_sundy 的专栏

网站建设,深圳网站建设,网页设计深圳,平面设计,深圳平面设计,深圳多媒体设计...

第一次遇到Mysql的BUG,困扰我好久了。

第一次遇到Mysql的BUG,困扰我好久了。

采用struts连接缓冲池取得数据库连接,在第一次getConnection()的时候
有时候出现一下错误
java.sql.SQLException: Communication link failure: java.net.SocketException, underlying cause: Software caused connection abort: recv failed

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Software caused connection abort: recv failed

STACKTRACE:

java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1449)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1826)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1153)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2048)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2017)
at com.mysql.jdbc.Connection.execSQL(Connection.java:1998)
at com.mysql.jdbc.Connection.setAutoCommit(Connection.java:516)
at org.apache.struts.legacy.GenericConnection.setAutoCommit(GenericConnection.java:562)
at com.euwsoftware.autocreatewebsite.database.mysql.MysqlDAOFactory.getConnection(MysqlDAOFactory.java:113)

** END NESTED EXCEPTION **



为解决方法(转自 http://bugs.mysql.com/bug.php?id=5020
MySQL Bugs: #5020: autoReconnect / autoReconnectForPools broken since 3.0.11
 Description:
Our Systems run 24 Hours a Day, but at night nobody connects,
so the Socket Connections time out. At morning the first attempts
to do anything (e.g. login) fail until we are able to close() and
create..() the Connections again.

This did not happen until after 3.0.11

How to repeat:
Connection reconnectableConn = DriverManager.getConnection(
        "jdbc:mysql:///test?autoReconnect=true");

rs = reconnectableConn.createStatement().executeQuery("SELECT 1");
assertTrue  (rs.next());
assertEquals(1, rs.getInt(1));

restartMySQL();  // Actually: NET STOP MySQL; NET START MySQL;

rs = reconnectableConn.createStatement().executeQuery("SELECT 1");
assertTrue  (rs.next());
assertEquals(1, rs.getInt(1));

...

java.sql.SQLException: Communication link failure:
java.net.SocketException, underlying cause:
Software caused connection abort: recv failed

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Software caused connection abort: recv failed

STACKTRACE:

java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1385)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1532)
...
** END NESTED EXCEPTION **
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1707)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1923)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1163)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1272)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1218)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2233)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2181)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1159)


Suggested fix:
Connections should properly reconnect when the Socket times out
or the connection is lost some other way.

Please contact me for a complete TestSuite based on your Regression Tests.
阅读更多
个人分类: JAVA / JSP
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

第一次遇到Mysql的BUG,困扰我好久了。

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭