org.hibernate.util.JDBCExceptionReporter – Communications link failure | SQL Error: 0, SQLState: 08S01
I noticed an exception like this one in one of our applications’ log and was investigating it. Here’s it:
Exception
[20:26:51] WARN [org.hibernate.util.JDBCExceptionReporter] – SQL Error: 0, SQLState: 08S01
[20:26:51] ERROR [org.hibernate.util.JDBCExceptionReporter] – Communications link failureLast packet sent to the server was 96429 ms ago.
. . .
org.springframework.dao.DataAccessResourceFailureException: Cannot open connection; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:627)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
Solution
Seems there was a stale connection at that point of time in Hibernate‘s C3P0 connection pool. MySQL might have timed out the connection, but C3P0 wasn’t probably configured with an appropriate value for idle_test_period and timeout properties, and hence the said connection might have stayed on without getting validated/removed. (The property idle_test_period defines the interval to test unchecked-out connections while timeout is the time unused connections can live in the pool.
If this is a one-off case, there’s no need to worry; just observe this failure over a period of time. If this happens frequently, we may need to double-check the values for above properties.

No comments yet
Jump to comment form | comment rss [?] | trackback uri [?]