数据库长时间没连接后的异常处理[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] -

Hibernate专题 2015/03/30

2014-12-31 01:16:48,258 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] -

2014-12-31 01:16:48,258 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] -

原因:You're probably running into the fact that MYSQL closes connections   
which have been open "too long". 
Probably if you make the request to the server again, you'll find that   
it works because the connection is reopened. 

解决方法:One way to deal with this is to add the following to your context.xml   

validationQuery="select 1"

代价:This causes a very cheap test query to always be run first; if the   
connection has been closed, this gets the failure, and 
then a new connection is opened