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: C3P0 with ExecutorService class
PostPosted: Tue Aug 21, 2007 11:24 pm 
Newbie

Joined: Tue Aug 21, 2007 5:48 am
Posts: 1
Hi everyone,

Is it a normal behaviour that C3P0 closes the connection shortly after creating it when Java's threading API is used?

I have a class that implements Runnable and is ran by the ExecutorService class. Hibernate initialises as usual and C3P0 creates the default 3 connections as shown in my log when the application starts up. However, shortly after, C3P0 starts shutting down the connections as shown below

Code:
2007-08-22 10:56:01,296 DEBUG [main] com.mchange.v2.c3p0.management.ActiveManagementCoordinator  - MBean: com.mchange.v2.c3p0:type=PooledDataSource[1hgea9s7o12pek701n30f9|1da669c] unregistered.
2007-08-22 10:56:01,296 DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1] com.mchange.v2.async.ThreadPoolAsynchronousRunner  - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#1,5,main] interrupted. Shutting down.
2007-08-22 10:56:01,296 DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0] com.mchange.v2.async.ThreadPoolAsynchronousRunner  - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#0,5,main] interrupted. Shutting down.
2007-08-22 10:56:01,296 DEBUG [com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2] com.mchange.v2.async.ThreadPoolAsynchronousRunner  - Thread[com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread-#2,5,main] interrupted. Shutting down.
2007-08-22 10:56:01,296 DEBUG [main] com.mchange.v2.c3p0.management.ActiveManagementCoordinator  - C3P0Registry mbean unregistered.
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.resourcepool.BasicResourcePool  - Preparing to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@d66426
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool  - Preparing to destroy PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@d66426
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.c3p0.impl.NewPooledConnection  - com.mchange.v2.c3p0.impl.NewPooledConnection@d66426 closed by a client.
java.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
   at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:491)
   at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:191)
   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.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:989)
   at com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:32)
   at com.mchange.v2.resourcepool.BasicResourcePool$5.run(BasicResourcePool.java:1174)
2007-08-22 10:56:01,296 DEBUG [main] com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource  - com.mchange.v2.c3p0.PoolBackedDataSource@1da669c has been closed.
java.lang.Exception: DEBUG STACK TRACE for PoolBackedDataSource.close().
   at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close(AbstractPoolBackedDataSource.java:417)
   at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close(AbstractPoolBackedDataSource.java:429)
   at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:359)
   at com.mchange.v2.c3p0.DataSources.destroy(DataSources.java:335)
   at org.hibernate.connection.C3P0ConnectionProvider.close(C3P0ConnectionProvider.java:182)
   at org.hibernate.impl.SessionFactoryImpl.close(SessionFactoryImpl.java:803)
   at com.wings.controller.JustAMain.main(JustAMain.java:46)
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool  - Successfully destroyed PooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@d66426
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.resourcepool.BasicResourcePool  - Successfully destroyed resource: com.mchange.v2.c3p0.impl.NewPooledConnection@d66426
2007-08-22 10:56:01,296 DEBUG [Resource Destroyer in BasicResourcePool.close()] com.mchange.v2.resourcepool.BasicResourcePool  - Preparing to destroy resource: com.mchange.v2.c3p0.impl.NewPooledConnection@186f247


It happens even before i can even do a transaction.beginTransaction(). Does anyone know why this is happening? This wouldn't happen if i did not use threads.

I am using Java SE 5 update 12, Hibernate 3.2.4 sp1, default C3P0 package and Oracle 10g Express Edition.

Any insight is greatly appreciated. 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.