-->
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: schema validate/update closes shared c3p0 ConnectionProvider
PostPosted: Mon Mar 06, 2006 12:42 pm 
Newbie

Joined: Mon Mar 06, 2006 9:14 am
Posts: 2
hi,

i encountered a bug (GenericJDBCException: Cannot open connection) which is very simple to reproduce:

- i use c3p0 connection pooling
- i use hbm2ddl.auto "validate" or "update"

it is reproducable by running the 'eg' example in the 3.1.2 distribution, but:
- with the Main.java altered in order to "update" the existing schema instead of "create"
- use c3p0 connection pooling in the hibernate.properties file (uncomment hibernate.c3p0.max_size 2)

it looks to me like a very common case, and i saw some comments on this forum with the same issue, but did not encounter any serious solutions.

looking in the source code, it is obvious that the third constructor of both SchemaUpdate and SchemaValidator get their ConnectionProvider from the settings, and this provider is closed when their tasks are done (in SchemaUpdate#execute / SchemaValidator#validate). after that, the first 'user' database access fails.

interesting is the fact that the first constructors of these classes *do* create a new ConnectionProvider. why isn't that done in the other constructors as well?

grtz,
martijn

Hibernate version:
3.1.2

Full stack trace of any exception that occurs:
[java] Setting up some test data
[java] 17:24:47,727 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: null
[java] org.hibernate.exception.GenericJDBCException: Cannot open connection
[java] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
[java] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
[java] at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
[java] at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
[java] at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:125)
[java] at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
[java] at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1309)
[java] at org.hibernate.auction.Main.createTestAuctions(Main.java:285)
[java] at org.hibernate.auction.Main.main(Main.java:370)
[java] Caused by: java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@100363 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@1e57
e8f [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, check
outTimeout -> 0, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityTo
ken -> 1e57e8f, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, maxIdleTime -> 0, maxPoolSize -> 2, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, nest
edDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@18941f7 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 18941f7, jdbcUrl -> j
dbc:hsqldb:., properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false,
usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 100363, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
[java] at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:234)
[java] at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:246)
[java] at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
[java] 17:24:47,727 ERROR JDBCExceptionReporter:72 - com.mchange.v2.c3p0.PoolBackedDataSource@100363 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDat
aSource@1e57e8f [ 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 -> 1e57e8f, idleConnectionTestPeriod -> 0, initialPoolSize -> 1, maxIdleTime -> 0, maxPoolSize -> 2, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSiz
e -> 1, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@18941f7 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 18941f7,
jdbcUrl -> jdbc:hsqldb:., properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnChecko
ut -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 100363, numHelperThreads -> 3 ] has been closed() -- you can no longer use
it.
[java] at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
[java] at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
[java] ... 6 more
[java] Exception in thread "main"


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 3:57 am 
Regular
Regular

Joined: Wed Sep 21, 2005 1:37 pm
Posts: 53
Location: Montpellier - France
I have the same error. I have removed the 'hbm2ddl.auto' property and It works but it is not fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 27, 2006 4:33 am 
Newbie

Joined: Mon Mar 06, 2006 9:14 am
Posts: 2
i had a short look in the code of release 3.1.3 and it looks like it's fixed there. it seems to be working for me now, but i've switched from c3p0 to common-dbcp, so i'm not shure if it works for c3p0 (but i think it does).


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.