[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-2343) SchemaUpdate and c3p0 connection pool too many connections

Grant Ingersoll (JIRA) noreply at atlassian.com
Wed Feb 7 10:29:40 EST 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2343?page=comments#action_26015 ] 

Grant Ingersoll commented on HHH-2343:
--------------------------------------

>From what I can tell (and I am not a Hibernate developer at all), this is happening due to the calls in generateSchemaUpdateScript() in Configuration.java

In this code, it does
for each table
     Settings settings = buildSettings()
     ....

Hence the reason it seems there is one call per table as reported in the initial report.

In buildSettings, there is a call to create the Connection Provider which initializes C3P0, etc. and creates the connections.  This seems like it should be fine, but my guess is that maybe these connections aren't being properly closed or garbage collected once generateSchemaUpdateScript is done?

I also wonder if that buildSettings call could be moved outside the loop.  I admit total naivety on how or why this works, am merely reporting on the results of my debugging. 

I also wonder if the original reporter, like me, is NOT using a JNDI DataSource.

> SchemaUpdate and c3p0 connection pool too many connections
> ----------------------------------------------------------
>
>          Key: HHH-2343
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2343
>      Project: Hibernate3
>         Type: Bug

>   Components: build
>     Versions: 3.2.1
>  Environment: hibernate 3.2.1.ga, hibernate-annotations, oracle ojdbc14_g 10.2.0.2, c3p0 0.9.0 or 0.9.0.4, Sun Java 1.5.0.10, Win XP.
>     Reporter: Vlad Skarzhevskyy

>
>
> - I have application, configured to use c3p0 as connection pool 
>   <property name="c3p0.max_size">2</property>
> - When SchemaUpdate is enabled
>   <property name="hibernate.hbm2ddl.auto">update</property>
>  
>   Application (hibernate) creates ~100 connections to database and  c3p0 pool initialized 42 times. (looks like number of entities in my domain)
>   There are no problems like this in hibernate 3.2.0.ga
> I see this log statement 42 times in log
> INFO  Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource at 15a4a77
>  [ ... initialPoolSize -> 2, ... maxPoolSize -> 2, ] 
> INFO  2007-01-04 13:39:55,796   2031- [..] 	 [C3P0Registry.banner:77]	 com.mchange.v2.c3p0.C3P0Registry.banner(C3P0Registry.java:77) [main]
> 	Initializing c3p0-0.9.0.4 [built 23-January-2006 22:20:29 -0500; debug? true; trace: 10]
> INFO  2007-01-04 13:39:56,093   2328- [..] 	 [PoolBackedDataSource.getPoolManager:257]	 com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:257) [main]
> 	Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource at bc312f [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource at 5f1ba8 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 5f1ba8, idleConnectionTestPeriod -> 3000, initialPoolSize -> 2, maxIdleTime -> 5000, maxPoolSize -> 2, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 2, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource at 13c4c09 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 13c4c09, jdbcUrl -> jdbc:oracle:thin:@torvspocapp:1522:ENT10, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> bc312f, numHelperThreads -> 3 ]
> ......
> And so on 42 times.
> hibernate.cfg.xml
> ----
>         <property name="hibernate.connection.pool_size">0</property>
>         <property name="c3p0.acquire_increment">1</property>
>         <property name="c3p0.min_size">2</property>
>         <property name="c3p0.max_size">2</property>
>         <property name="c3p0.timeout">5000</property>
>         <property name="c3p0.idle_test_period">3000</property>
>         <property name="c3p0.max_statements">100</property>
>       
>        <property name="hibernate.hbm2ddl.auto">update</property>
>         <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
> ----

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira





More information about the hibernate-issues mailing list