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"
|