Let me describe my question -
I have a Java application - Hibernate as the DB interfacing layer over MySQL. I get the communications link failure error in my applic
I had issue before. It looks like MySQL server times out your connection. Timeout is 28800 by default which is 8 hours. Please refer to this link for more details.
http://shengchien.blogspot.com/2009/10/hibernate-c3p0-and-mysql.html
Hope it is useful to you.
Here is an account of how I finally solved this - http://vatsalad.wordpress.com/2010/09/28/hibernate-communications-link-error-c3p0mysql-and-broken-pipe-error/
Even I faced this error, I got it solved only after enabling autoReconnect=true in c3p0 config
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ex_app?autoReconnect=true</property>
I solved my communication link failure with c3p0. I came across the blog below that explained that the org.hibernate version must be equal to the c3p0 version, so this is the pom configuration that made my day
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>4.3.6.Final</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
like he explains, it was enough to add only one property to hibernate.cfg.xml to get c3p0 pooling
<property name="hibernate.c3p0.min_size">10</property>
no more "communication link error" , "expected to read 5 bytes,read 0" after that. here is the link:https://howtodoinjava.com/hibernate/hibernate-c3p0-connection-pool-configuration-tutorial/