-->
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.  [ 5 posts ] 
Author Message
 Post subject: Connection is invalid
PostPosted: Mon Sep 04, 2006 8:55 am 
Newbie

Joined: Tue Mar 21, 2006 4:19 am
Posts: 15
When working with hibernate i get this exception:

Code:
java.sql.SQLException: Connection is invalid
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.testPooledConnection(C3P0PooledConnectionPool.java:196)
   at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1.refurbishIdleResource(C3P0PooledConnectionPool.java:136)
   at com.mchange.v2.resourcepool.BasicResourcePool$AsyncTestIdleResourceTask.run(BasicResourcePool.java:1394)
   at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:368)
15:25:51,424 WARN  [BasicResourcePool] BasicResourcePool: An idle resource is broken and will be purged.


What that means?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 06, 2006 8:06 pm 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Hi.

This means that you have c3p0 configured to periodically test Connections in the pool, and c3p0 has found a Connection that seems broken, and has removed it from the pool. You can safely just ignore this if it's infrequent.

If you are getting a lot of these messages, you might try to track down why Connections are going bad. Often what happens is that databases time out unused Connections. Setting parameters c3p0 parameters like maxIdleTime can cause c3p0 to discard Connections before they time out, that the pool sees stale Connections less frequently.

smiles,
Steve


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 12, 2006 10:17 pm 
Newbie

Joined: Tue Dec 12, 2006 10:12 pm
Posts: 2
I'm getting a lot of these...

The thing is, I tried to set maxIdle lower than the connection test period so that idle connections would be purged before the test interval expired.

Here's my props file (note that I have configured all these through Hibernate not through the c3p0.properties file)

hibernate.c3p0.min_size=5
hibernate.c3p0.max_size=20
hibernate.c3p0.acquire_increment=2
hibernate.c3p0.timeout=1800 <---- lower than
hibernate.c3p0.max_statements=0
hibernate.c3p0.idle_test_period=3600 <----- this

I dont see any console msgs when the timeout occurs, only the warnings when the connection test process finds stale conns and purges them.

Is there anything I can do to reduce the noise on my console?

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 12:50 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
adam, are you sure the parameters you're setting are the ones c3p0 is seeing? check out c3p0's config dump on initialization to verify the params. if you want to turn the idle test off, just set hibernate.c3p0.idle_test_period to 0. that said, i don't know how or why you'd see idle tests with your timeout setting.

what version of c3p0 are you using? recent c3p0s log failed idle tests at a debug log level.

i'd still like to understand why you are seeing idle tests rather than timeouts with these settings. if you do try the latest (c3p0-0.9.1-pre11, please do try with com.mchange.v2.resourcepool.BasicResourcePool logged at DEBUG or FINER. the internal resource pool will dump its config at this level, and we can see whether you are still showing idle tests with your settings. (i'll try to reproduce this on my end as well.)

good luck, steve


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 13, 2006 1:13 am 
Newbie

Joined: Tue Dec 12, 2006 10:12 pm
Posts: 2
Gee, do ya think putting the version number in my message would have been a good idea? I'm running 0.9.0.4

Here's initialization:

Code:
12 Dec 2006 21:02:30,087  INFO C3P0Registry:77 - Initializing c3p0-0.9.0.4 [built 23-January-2006 22:20:29 -0500; debug? true; trace: 10]
12 Dec 2006 21:02:30,807  INFO PoolBackedDataSource:257 - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@a083f2 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@387202 [ acquireIncrement -> 2, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 387202, idleConnectionTestPeriod -> 3600, initialPoolSize -> 5, maxIdleTime -> 1800, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1335b86 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1335b86, jdbcUrl -> jdbc:jtds:sqlserver://erslab4.ucop.edu:1181/erstrain, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> a083f2, numHelperThreads -> 3 ]


Not that long ago I enabled idleTest because users seemed to be getting connections from the pool that were actually dead, and this did fix the problem.

I'll grab 0.9.1-pre11 and set that up in my test environment.


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