Hibernate JDBCConnectionException: Communications link failure and java.io.EOFException: Can not read response from server

Posted by Marc on Stack Overflow See other posts from Stack Overflow or by Marc
Published on 2012-03-19T09:54:20Z Indexed on 2012/03/19 10:03 UTC
Read the original article Hit count: 290

Filed under:
|

I get a quite well-known using MySql jdbc driver : JDBCConnectionException: Communications link failure, java.io.EOFException: Can not read response from server. This is caused by the wait_timeout parameter in my.cnf. So I decided to use c3p0 pool connection along with Hibernate. Here is what I added to hibernate.cfg.xml :

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.min_size">10</property>
<property name="c3p0.max_size">100</property>
<property name="c3p0.timeout">1000</property>
<property name="c3p0.preferredTestQuery">SELECT 1</property>
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">2</property>
<property name="c3p0.max_statements">50</property>

idle_test_period is volontarily low for test purposes. Looking at the mysql logs I can see the "SELECT 1" request which is regularly sent to the mysql server so it works. Unfortunately I still get this EOF exception within my app if I wait longer than 'wait_timout' seconds (set to 10 for test purposes).

I'm using Hibernate 4.1.1 and mysql-jdbc-connector 5.1.18.

So what am I doing wrong?

Thanks, Marc.

© Stack Overflow or respective owner

Related posts about hibernate

Related posts about c3p0