-->
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: C3P0 and SessionFactory configuration. Please help!
PostPosted: Tue Jan 09, 2007 11:08 am 
Newbie

Joined: Wed Oct 26, 2005 3:37 am
Posts: 15
Hibernate version: 3.2

Name and version of the database you are using: MySql 5.1

Hello! I am stuck!

I try to configure c3p0 connection pooling.
So I have in hibernate.cfg.xml:

Code:
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.max_size">20</property>


Then, in my application, I have to create a session factory for each one of number of databases I have:

Code:

for (String dbname: ...) {
            Configuration cfg = new AnnotationConfiguration().configure("hibernate_rpx.cfg.xml");
            cfg.setProperty("hibernate.connection.url", "jdbc:mysql://"+dbname);
           
            SessionFactory sf = cfg.buildSessionFactory();
           
            sessionFactories.put(app, sf);
}


So far so good. The problem is that during the buildSessionFactory method, a large amount of initial connections are established - like 100 per a database. So soon the maximum number of connections to the database server is exausted.
I think that the number of connection is related to the number of annotated classes - since when there are only 2 classes, only 4 connections are created. As if each DDL statement (updating db model) is causing many new connections to be created.

Debug info from c3p0:

[System][INFO ] Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1159e0c [ connectionPoolDataSource ->
com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1b1ab1d [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquir
eRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkout
Timeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> nul
l, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1b1ab1d, idleConnectionTestPeriod -> 0, initialPoolSize
-> 1, maxIdleTime -> 0, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, nested
DataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1e2f6b0 [ description -> null, driverClass -> null, factoryCla
ssLocation -> null, identityToken -> 1e2f6b0, jdbcUrl -> jdbc:mysql://localhost/rpx, properties -> {user=******, passwor
d=******, server=localhost} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testC
onnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -
> 1159e0c, numHelperThreads -> 3 ]

Have anyone else had such situation? Any help would be appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 12:01 pm 
Newbie

Joined: Wed Oct 26, 2005 3:37 am
Posts: 15
Damn, is this HHH-2032 (http://opensource.atlassian.com/project ... e/HHH-2032)?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 09, 2007 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
nope - is more the issue of schemavalidator calling buildSettings too often.

fixed in svn (can't make jira work right now)

_________________
Max
Don't forget to rate


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.