On Thu, 2012-01-26 at 07:46 -0800, Jerry Malcolm wrote: > I migrated to Tomcat 7.0 a couple of months ago on several servers. Ever > since moving to 7, I periodically get the following exception on MySql > calls on all of my 7.0 servers: > > Exception: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The > last packet successfully received from the server was 71,072,547 > milliseconds ago. The last packet sent successfully to the server was > 71,072,578 milliseconds ago. is longer than the server configured value of > 'wait_timeout'. You should consider either expiring and/or testing > connection validity before use in your application, increasing the server > configured values for client timeouts, or using the Connector/J connection > property 'autoReconnect=true' to avoid this problem. > > My data source configuration is: > > <Resource name="jdbc/xxxxxxxxxxxxxx.com" auth="Container" > type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" > removeAbandoned="true" removeAbandonedTimeout="60" logAbandoned="true" > username="xxxxxxx" password="xxxxxxx" > driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql:// > 127.0.0.1/xxxxxxxxx?autoReconnect=true"/> > > I realize that, yes, the 71k seconds is greater than the 10k maxWait and I > could increase maxWait. But that would not be fixing the problem. The > exception text says to use autoReconnect=true. But I already have > autoReconnect=true, and I'm certain this was working back on 5.0 (I went > from 5.0 to 7.0).
I agree that it looks like you have specified autoReconnect correctly, but I'm no expert there. I believe that autoReconnect is a feature of the JDBC driver, so you might want to check with the MySQL folks to see why that is not working. > > I also know I could (and probably should) add defensive code to check for > connection validity. But again, this all worked fine for years on 5.0. Have you tried using the validation offered by the connection pool? If you set "testOnBorrow=true" and "validationQuery=SELECT 1", the pool should validate connections without requiring any code changes to your application. See commons-dbcp configuration docs. https://commons.apache.org/dbcp/configuration.html Dan > > It appears that autoReconnect is no longer working. Has the configuration > syntax changed for autoReconnect since 5.0? > > Thx > > Jerry