MySql JDBC timeout even with 'autoReconnect = true'

Sometimes my Java / Tomcat6 / Debian Squeeze application cannot talk to the MySql server. The Tomcat application is located on the front-end server, and MySql is in a separate MySql window. Typical error:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was56588 milliseconds ago.

The last packet sent successfully to the server was 56588 milliseconds ago, which 
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.

The wait time is only 60 seconds, which seems very short. If it were an hour or more, I would just set the background job to a ping DB-server every few minutes. I added the autoReconnect parameter to the opening URL, with no visible effect.

Any idea what the problem is here? thanks Pat

+5
source share
2 answers

You must encode network failures and auto-reconnect.

auto-reconnect - , , .

, , .

0

c3p0 . ,

hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.min_size=0
hibernate.c3p0.max_size=20
hibernate.c3p0.timeout=500
hibernate.c3p0.max_statements=50
hibernate.c3p0.idle_test_period=3000
hibernate.c3p0.testConnectionOnCheckout=true
hibernate.c3p0.acquire_increment=1

URL- JDBC url=jdbc:mysql://host/databasename?autoReconnect=true

0

All Articles