-->
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.  [ 1 post ] 
Author Message
 Post subject: Oracle sessions continue growing up
PostPosted: Thu May 07, 2009 5:39 am 
Newbie

Joined: Thu May 07, 2009 4:44 am
Posts: 1
Hi All,
I'm developing a web application with Oracle 10.2 and I'm having a problem regarding the continue growing up of sessions on database.
I configure hibernate with c3p0 as follow:
Code:
       <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
        <property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.idle_test_period">70</property>
        <property name="hibernate.c3p0.min_size">5</property>
        <property name="hibernate.c3p0.max_size">40</property>
        <property name="hibernate.c3p0.timeout">180</property>
        <property name="hibernate.c3p0.max_statements">50</property>

        <property name="hibernate.generate_statistics">false</property>
        <property name="hibernate.c3p0.validate">true</property>
        <property name="hibernate.cache.use_second_level_cache">false</property>

        <property name="hibernate.connection.SetBigStringTryClob">true</property>
        <property name="current_session_context_class">thread</property>
        <property name="hibernate.jdbc.batch_size">0</property>
        <property name="hibernate.dbcp.ps.maxIdle">0</property>

        <property name="show_sql">true</property>
        <property name="format_sql">true</property>


What I cannot understand is why on my database there are more than the configured maximum 40 sessions.
Reading the documentation I'm expecting that configuring the property hibernate.c3p0.max_size to 40, that's the maximum number of sessions I have to found in my Oracle application database.

Java code is the following:
Code:
/* This is the class that instantiate the session factory */
public class HibernateUtil {

   private static SessionFactory sessionFactory;
      
   // this method is called once in the web application startup
   public static void init() throws Exception{
      try {
         sessionFactory = new Configuration().configure().buildSessionFactory();
      }
      catch (Exception ex) {}
      }
   }
   
   public static SessionFactory getSessionFactory() throws Exception {
      return sessionFactory;
   }
}


For each SQL statement (select, update, insert) I use the following schema:
Code:

public void myMethodSql()
{
      ResultSet rset=null;
      PreparedStatement ps=null;
      
      try{   
         HibernateUtil.getSessionFactory().getCurrentSession().beginTransaction();
         
         String mySQLStatement = "SELECT * FROM ....";
         ps = HibernateUtil.getSessionFactory().getCurrentSession().connection().prepareStatement(mySQLStatement);
         rset = ps.executeQuery();         
         // ...parse Result Set ...
         
         HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
      }
      catch(Exception e) {
         try {
            HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().rollback();
         } catch (Exception e1) {}
      }
      finally {
         if (rset!=null) {
            try {
               rset.close();
            } catch (SQLException e) {}
         }
         if (ps!=null) {
            try {
               ps.close();
            } catch (SQLException e) {}
         }
      }
}

Should I have to close session after commit/rollback using:
Code:
HibernateUtil.getSessionFactory().getCurrentSession().close();


I'm not using (and I don't want use) hibernate sql language. Also I don't (want to) map all database tables.

Thanks.


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

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.