Reputation: 21
i am searching the solution for the below problem , if you have any idea please share when I try to run a single query from java (jboss server), am getting the below exception (not frequently .)
Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
The last packet successfully received from the server was43200 seconds ago. The last packet sent successfully to the server was 43200 seconds 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.*
if connection is idle, it is closed by MySQL. in this case Java will give Can not write: broken pipe" or alike exception but in this case, connection is not idle. it is working. so MySQL won’t close it. but Java is waiting for query result and cannot get it for 12 hours so it shows "Read Timeout" exception
Upvotes: 0
Views: 109
Reputation: 240908
You need to use connection pool that manages these things for you, refer c3po, basic idea is you make a dummy query to keep connection alive periodically
Upvotes: 2