Wednesday, May 30, 2012

Java application with hibernate stops working after a few hours of not being used

I have a tomcat - hibernate web application, but after a night of not being used - the application stops working and shows exceptions and I need to restart the app in tomcat.

The issue seems to be related to the fact the hibernate drops the connection after a configurable amount of time and doesn't know how to reconnect.

Th solution lays in C3P0 package.

See here:
http://www.databasesandlife.com/automatic-reconnect-from-hibernate-to-mysql/