-->
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.  [ 2 posts ] 
Author Message
 Post subject: Correspondence of pool size and the number of db-connections
PostPosted: Mon Apr 19, 2004 11:40 pm 
Newbie

Joined: Mon Apr 19, 2004 11:27 pm
Posts: 9
on Hibernate 2.1.2 (and MySQL 4.1.x):

Hi folks.
I want to confirm correspondence of pool size and the number of database connections.
How can I confirm about Hibernate uses appropriately the connection-pooling set up by 'hibernate.connection.pool_size'?

I coded :
Code:
public class TestHibernateSession {

    private SessionFactory sessionFactory = null;
    private ThreadLocal session = null;

    public static void main(String[] args) throws HibernateException {
        new TestHibernateSession();
    }
   
    public TestHibernateSession()  throws HibernateException  {
        sessionFactory = new Configuration().configure().buildSessionFactory();
        session = new ThreadLocal();

        Session sess1 = (Session)session.get();
        if(sess1 == null){
            sess1 = sessionFactory.openSession();
            session.set(sess1);
        }
        Session sess2 = (Session)session.get();

        if(sess2 == null){
            sess2 = sessionFactory.openSession();
            session.set(sess2);
        }
        Session sess3 = (Session)session.get();
        if(sess3 == null){
            sess3 = sessionFactory.openSession();
            session.set(sess3);
        }

        System.out.println( "sess1 : " + System.identityHashCode(sess1.connection()));
        System.out.println( "sess2 : " + System.identityHashCode(sess2.connection()));
        System.out.println( "sess3 : " + System.identityHashCode(sess3.connection()));

        sess1.close();
        sess2.close();
        sess3.close();
        sessionFactory.close();
       
    }
}


and, setup in hibernate.cfg.xml:
<property name="hibernate.connection.pool_size">2</property>

'hibernate.properties' is not available.

I get message in console when program running:
>sess1 : 19147537
>sess2 : 19147537
>sess3 : 19147537

I expect the result of using 'System.identityHashCode()' from which each differs.
or, is this means a mistake primarily?

best regards,
Thanks.


Top
 Profile  
 
 Post subject: Sorry, It solved.
PostPosted: Tue Apr 20, 2004 1:11 am 
Newbie

Joined: Mon Apr 19, 2004 11:27 pm
Posts: 9
I did not set up connection pooling in properties.
(configuration.getProperty(Environment.CONNECTION_PROVIDER) = null)

I tested follow setting using c3po:
Code:
<property name="c3p0.min_size">1</property>
<property name="c3p0.max_size">2</property>
<property name="c3p0.max_statements">10</property>
<property name="c3p0.timeout">100</property>
<property name="c3p0.validate">true</property>
<property name="hibernate.connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>


(configuration.getProperty(Environment.CONNECTION_PROVIDER) = net.sf.hibernate.connection.C3P0ConnectionProvider)

The overflowing session is waiting for the until using session will be released.

Sorry and thx !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.