MySql timeouts - Should I set autoReconnect=true in Spring application?

Posted by George on Stack Overflow See other posts from Stack Overflow or by George
Published on 2010-03-09T03:49:07Z Indexed on 2010/03/09 3:51 UTC
Read the original article Hit count: 597

Filed under:
|
|
|
|

After periods of inactivity on my website (Using Spring 2.5 and MySql), I get the following error:

org.springframework.dao.RecoverableDataAccessException: The last packet sent successfully to the server was 52,847,830 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.

According to this question, and the linked bug, I shouldn't just set autoReconnect=true. Does this mean I have to catch this exception on any queries I do and then retry the transaction? Should that logic be in the data access layer, or the model layer? Is there an easy way to handle this instead of wrapping every single query to catch this?

© Stack Overflow or respective owner

Related posts about java

Related posts about jdbc