tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud <>
Subject Re: connection autoReconnect?
Date Tue, 20 Nov 2012 09:23:54 GMT
We have been struggling with this MySQL last packet message for some times as
well. And we are still not sure if we have solved it yet. However we did
discover quite a few things.

We minimized our DBCP configuration to only a few parameters
<Context path="">
  <Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
            name="jdbc/retailUser" type="javax.sql.DataSource"
            username="xxxxxx" password="xxxxx"
            validationQuery="SELECT 1" testOnBorrow="true"/>

 That's it. All the other parameters have acceptable default values. The
problem, we think, is actually that with the default configuration you will
open to many connections and not use them within the wait_timeout of MySQL.
So, now and then you will retrieve a connection that has timed out. The
validation query solves this.

As far as we know the autoReconnect is a jConnector parameter and only
applies to MySQL. MySQL says in their documentation that it's the
applications job to handle failed connections. For the step of just getting
the connection DBCP is solving this with the validationQuery="SELECT 1"
testOnBorrow="true" settings. But if it happens in the midst of a
transaction, your application should handle it.

If you do not set validationQuery than testOnBorrow will simply not run.

removeAbandoned only removes connections that you forget to close in your
application. You can use this setting for a while together with logAbandoned
to find your application leaks where you forget to close the connection
after use, but when done you should remove logAbandoned because the logging
adds overhead from every connection borrowed.

Most of this we found at
<>   and at

View this message in context:
Sent from the Tomcat - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message