My app got the error:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.
at sun.reflect.GeneratedConstructorAccessor281.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
When my app sees that error it automatically retry the operation. But when I did a tcpdump and I don’t see any new tcp connection is created at that time. It looks like the same tcp connection is used. So why I get the exception? My app uses c3p0 connection pool and I set c3p0 to test connection before check in. Is there any settings to mysql driver or c3p0 to get around this problem?
testConnectionOnCheckin alone is insufficient to ensure that Connections don’t time out in the pool. if the pool is not very busy, Connections may remained checked-in and idle indefinitely. testConnectionOnCheckin should be combined with idleConnectionTestPeriod, so that idle Connections are periodically verified as well.
see http://www.mchange.com/projects/c3p0/#configuring_connection_testing
good luck!