wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC Timeout issue with MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Timeout issue with MySQL" Watch "JDBC Timeout issue with MySQL" New topic

JDBC Timeout issue with MySQL

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
Despite having tried everything suggested, I'm still getting connection failures after 8 or so hours from my Servlet using Connector/J and MySQL.

Per David's suggestion, I added ?autoReconnect=true to the properties file that has the database login information. I also added the .newInstance() method call to the database connection code (I've read things that say to use .newInstance() and others that say NEVER use it).

Here's the error I keep getting. Any help or suggestions about what I might try next would be *GREATLY* appreciated!!!

-- Mike


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


MESSAGE: Software caused connection abort: recv failed


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.read1(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1391)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1538)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1224)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2244)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2192)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1163)
at chat.ChatProcs.doQuery(ChatProcs.java:508)
at chat.ChatProcs.userExists(ChatProcs.java:387)
at chat.Dispatcher.doPost(Dispatcher.java:279)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1034
If you look at pages in Google using the search phrase:

Communication link failure: java.net.SocketException

You'll see lots of people who have tried the connection pooling approach, the ?autoReconnect=true approach and, all the links I went to said that after 8 hours, MySQL's timeout happned anyway, no matter what.

I'm not sure what to try next... This doesn't sound like it's configurable.

I hope someone knows what's going on and what will actually re-connect to the database after the timeout ....

Thanks in advance!!!

-- Mike
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 29220

That parameter doesn't keep your database connection alive, it just gets one automatically on the first failure. So if you write some custom code, you can get around the problem. If the query fails the first time, try again. The second time is likely to work as the connection will have reconnected.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: JDBC Timeout issue with MySQL
Similar Threads
new to db connection help needed
Communications link failure in JBOSS
error: Communications link failure due to underlying exception
MySQL connection is dropped before wait_timout is elapsed
Why I get CommunicationsException using Quartz JobStore web application ?