File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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: 1130
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:, underlying cause: Software caused connection abort: recv failed

MESSAGE: Software caused connection abort: recv failed

STACKTRACE: Software caused connection abort: recv failed
at Method)
at Source)
at Source)
at Source)
at Source)
at com.mysql.jdbc.MysqlIO.readFully(
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.MysqlIO.sqlQuery(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.Connection.execSQL(
at com.mysql.jdbc.Statement.executeQuery(
at chat.ChatProcs.doQuery(
at chat.ChatProcs.userExists(
at chat.Dispatcher.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
at Source)

Mike London
Ranch Hand

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

Communication link failure:

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
author & internet detective

Joined: May 26, 2003
Posts: 33119

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.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: JDBC Timeout issue with MySQL
It's not a secret anymore!