I use the C3P0 connection pool with Hibernate to perform some JDBC operations. However, I get the message “Closed connection” (SQL error: 17008, SQLState: null) after some time of use.
I use the org.hibernate.jdbc.Work interface to perform my operations:
public class ClassThatDoesWork implements Work { @Override public void execute(final Connection connection) throws SQLException { doSomeWork();
My question is: should the connection object be passed as an argument to the execute() method at the end of this method, or will Hibernate take care of this automatically?
EDIT These are the Hibernate and c3p0 parameters:
hibernate.connection.driver_class=oracle.jdbc.driver.OracleDriver hibernate.connection.pool_size=10 hibernate.dialect=org.hibernate.dialect.Oracle9iDialect hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider hibernate.show_sql=false acquireIncrement=3 acquireRetryDelay=500 acquireRetryAttempts=5 breakAfterAcquireFailure=false checkoutTimeout=0 connectionTesterClassName=com.mchange.v2.impl.DefaultConnectionTester debugUnreturnedConnectionStackTraces=false dataSourceName=irrelevantDB identityToken=irrelevantDB idleConnectionTestPeriod=0 initialPoolSize=3 maxConnectionAge=0 maxIdleTime=7200 maxIdleTimeExcessConnections=0 maxPoolSize=20 maxStatements=50 maxStatementsPerConnection=0 minPoolSize=5 numHelperThreads=3 propertyCycle=0 testConnectionOnCheckin=false testConnectionOnCheckout=true unreturnedConnectionTimeout=0 hibernate.c3p0.min_size=5 hibernate.c3p0.max_size=20 hibernate.c3p0.timeout=10 hibernate.c3p0.max_statements=50
nekojsi
source share