Will Hibernate C3P0 Initialize on tomcat startup

Hi All,
I using org.hibernate.connection.C3P0ConnectionProvider as my connection Provider class to connect to my oracle DB using Java.

My initialPoolSize -> 0 and minPoolSize -> 0, maxPoolSize -> 20 But in my catalina logs I can see the message Initializing c3p0 pool during the program start up and I’m able to see the error from DB (DB is temporarily down) inside the logs.

Does it mean that during the tomcat start up it will make a connection to Database. Since Database is down it will retry to make the connection? Any one able to give me a correct explanation. Thanks in advance.

Here is some of my properties

com.mchange.v2.c3p0.PoolBackedDataSource@62bb9e11 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@f4f04ca5 [ acquireIncrement -> 3, acquireRetryAttempts -> 1, acquireRetryDelay -> 3000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 10000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 31s7519vmrrbf9vfcwit|17cb546b, idleConnectionTestPeriod -> 0, initialPoolSize -> 0, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 60, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 0, preferredTestQuery -> SELECT 1, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 31s7519vmrrbf9vfcwit|3c1df42e, numHelperThreads -> 3 ]

And, during bootstrap, the C3P0ConnectionProvider will be initialized and connections will be created if you set an initial pool size that’s greater than 0.

Hibernate needs the database to be up and running when you start Tomcat because the SessionFactory needs the database metadata especially if you are using the hbm2ddl tool.

Hi thanks for the reply, but we are not using any hbm2ddl tool.

So can I conclude that even though the initialPoolSize is set to 0, when tomcat startup it will try to connect to the DB. So DB is giving some error iam seeing the same error in my catalina logs.

The JdbcEnvironmentInitiator uses a Connection to fetch the DatabaseMetadata.

If you don’t want that, you can set the hibernate.temp.use_jdbc_metadata_defaults property to false, in which case, Hibernate will skip the connection acquisition during bootstrap.

Thank you for the reply. I am encountering the above issue for my staging environment. My staging and testing environment uses the same Hibernate configuration file and same Java Libraries.

But in my testing environment I have tried to change the JDBC connection URL to an invalid IP address (and tried after shutting down the database) but is not giving me any error in catalina logs during startup.

Are you able to help me to suggest what will be the possible cause of this behavior. ?

Most likely the settings are read from somewhere else. Only if you debug the ConnectionProvider code you will see where it gets the Connection from.

Thank you, but we are using same connection provider also, which is

It does not matter. I’m talking about what DB conbections settings that are found. That’s why you need to debug it.