Add this to persist.xml or if using straight hibernate add to the hibernate configuration:
<properties>
<property name="hibernate.connection.username" value="frank" />
<property name="hibernate.connection.password" value="Jane6194" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.c3p0.acquire_increment" value="3"/>
<property name="hibernate.c3p0.idle_test_period" value="14400"/>
<property name="hibernate.c3p0.timeout" value="25200"/>
<property name="hibernate.c3p0.max_size" value="15"/>
<property name="hibernate.c3p0.min_size" value="3"/>
<property name="hibernate.c3p0.max_statements" value="0"/>
<property name="hibernate.c3p0.preferredTestQuery" value="select 1;"/>
</properties>
It checks for invalid connections in the cache. By default, MySQL timesout after 8 hours of inactivity