We have a webapp running Hibernate/C3PO 4.1.4.Final, Jetty, Java 6, and Mysql 5.1.63.
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Communications link failure
The last packet successfully received from the server was 238,519 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
Our persistence.xml's properties section looks like this...
<properties>
<property name="hibernate.show_sql" value="false"/>
<!--Begin Credentials -->
<property name="hibernate.connection.url"
value="${rp.config.db.url}&useUnicode=true&characterEncoding=UTF-8"/>
<property name="hibernate.connection.username" value="${rp.config.db.user}"/>
<property name="hibernate.connection.password" value="${rp.config.db.password}"/>
<!--End Credentials -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.dialect" value="com.printlogix.rp.server.utils.Mysql5BitBooleanDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<!--C3PO -->
<property name="hibernate.connection.provider_class"
value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.acquire_increment" value="25"/>
<property name="hibernate.c3p0.idle_test_period" value="60"/>
<property name="hibernate.c3p0.timeout" value="120"/>
<property name="hibernate.c3p0.max_size" value="150"/>
<property name="hibernate.c3p0.min_size" value="25"/>
<property name="hibernate.c3p0.max_statement" value="0"/>
<property name="hibernate.c3p0.preferredTestQuery" value="select 1;"/>
</properties>
Our timeout on MySQL is set to 600 seconds. We have no idea how this is happening 1/5 times. The server has very little load, the database is relatively small, the servlets all run within seconds.
Anybody have any ideas?
This article explains the fix. C3P0 does not reconnect when a connection is expired.
http://www.databasesandlife.com/automatic-reconnect-from-hibernate-to-mysql/
It seems completely insane that the developers at Hibernate would not document this better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With