-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Still getting ORA-02396. Please advice.
PostPosted: Fri Feb 12, 2010 12:35 pm 
Newbie

Joined: Wed Nov 25, 2009 11:35 am
Posts: 17
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


Top
 Profile  
 
 Post subject: Re: Still getting ORA-02396. Please advice.
PostPosted: Mon Feb 15, 2010 6:54 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi,

you should get rid of this problem by specifying on c3p0 a Maximum connection idle time
slightly minor to the Maximum idle time you have set on the Oracle database server.
In this way c3p0 should close the idle connection before the Oracle database server does.


Top
 Profile  
 
 Post subject: Re: Still getting ORA-02396. Please advice.
PostPosted: Tue Feb 16, 2010 6:54 am 
Newbie

Joined: Wed Nov 25, 2009 11:35 am
Posts: 17
Thank you, pb00067. It works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.