Hi,
could anybody advice why doesn't c3p0 handle ORA-02396 silently ?
I'm very new to c3p0. I thought it has to handle ORA-02396 (exceeded maximum idle time, please connect again) but instead i'm getting:
Code:
Caused by: java.sql.SQLException: ORA-02396: exceeded maximum idle time, please connect again
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:589)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1957)
at oracle.jdbc.ttc7.TTC7Protocol.executeFetch(TTC7Protocol.java:975)
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2727)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2896)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:644)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:570)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
... 12 more
Feb 12, 2010 6:19:32 PM com.mchange.v1.db.sql.StatementUtils attemptClose
WARNING: Statement close FAILED.
java.sql.SQLException: ORA-01012: not logged on
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oclose.receive(Oclose.java:124)
at oracle.jdbc.ttc7.TTC7Protocol.close(TTC7Protocol.java:693)
at oracle.jdbc.driver.OracleStatement.close(OracleStatement.java:725)
at oracle.jdbc.driver.OraclePreparedStatement.privateClose(OraclePreparedStatement.java:522)
at oracle.jdbc.driver.OraclePreparedStatement.close(OraclePreparedStatement.java:430)
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:41)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.synchronousDestroyStatement(GooGooStatementCache.java:413)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache.closeAll(GooGooStatementCache.java:351)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeAllCachedStatements(NewPooledConnection.java:673)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:543)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:470)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
My code:
Code:
String str = "jdbc:oracle:thin:are_rq73/********@isd201.ISD.DP.UA:1521:dab";
cfg.setProperty("hibernate.connection.url", str);
cfg.setProperty("hibernate.show_sql", "true");
cfg.setProperty("hibernate.c3p0.max_size","1");
cfg.setProperty("hibernate.c3p0.min_size","0");
cfg.setProperty("hibernate.c3p0.timeout","5000");
cfg.setProperty("hibernate.c3p0.max_statements","100");
cfg.setProperty("hibernate.c3p0.idle_test_period","300");
cfg.setProperty("hibernate.c3p0.acquire_increment","1");
cfg.configure();
SessionFactory sessionFactory = cfg.buildSessionFactory();
Session session = sessionFactory.openSession();
System.out.println(session.get(Batch.class, Integer.valueOf(31066))) ;
session.close();
Thread.sleep(1000*60*3 + 1000*15);
int iter = 3;
do {
iter--;
try{
session = sessionFactory.openSession();
System.out.println(session.get(Batch.class, Integer.valueOf(31247)));
session.close();
break ;
} catch (Exception ex) {ex.printStackTrace();}
} while (iter > 0);
System will fail on first iteration, and finally select object on second.
Max idle is set to 3 min.
Thank you