Hi....
c3p0 is not able to get connection from the MySQL database as specified in the hibernate-cfg.xml Below is the error log and the configurarion file
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">false</property>
<!-- JDBC Driver -->
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- Connection URL -->
<!-- Development Settings -->
<property name="connection.url">jdbc:mysql://localhost:3306/epw3</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<!-- Dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- JDBC connection pool (use the built-in) -->
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- JDBC connection pool (use the built-in) -->
<!-- <property name="hibernate.connection.pool_size">5</property>-->
<!-- connection pool *** TO BE TUNED *** -->
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">50</property>
<property name="c3p0.timeout">100</property>
<property name="c3p0.max_statements">400</property>
<property name="c3p0.idle_test_period">1000</property>
<!-- cache settings *** TO BE TUNED *** -->
<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="cache.use_second_level_cache">true</property>
<property name="cache.use_query_cache">true</property>
<property name="cache.use_structured_entries">true</property>
<property name="generate_statistics">true</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- Drop and re-create the database schema on startup-->
<property name="hbm2ddl.auto">update</property>
<mapping resource="net/earthlink/epw3/model/UserAcct.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct0.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct1.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct2.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct3.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct4.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct5.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct6.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct7.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct8.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/UserAcct9.hbm.xml" />
<mapping resource="net/earthlink/epw3/model/Key.hbm.xml" />
</session-factory>
</hibernate-configuration>
following was the error log
Code:
13:36:16,061 [WARN ] [resourcepool.BasicResourcePool][run] [com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask@38462a -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30).]
13:36:16,967 [WARN ] [util.JDBCExceptionReporter][logExceptions] [SQL Error: 0, SQLState: null]
13:36:16,967 [ERROR] [util.JDBCExceptionReporter][logExceptions] [com.mchange.v2.c3p0.PoolBackedDataSource@83020 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@190d8e1 [ 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 -> 190d8e1, idleConnectionTestPeriod -> 1000, initialPoolSize -> 5, maxIdleTime -> 100, maxPoolSize -> 50, maxStatements -> 400, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@ae97c4 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> ae97c4, jdbcUrl -> jdbc:mysql://localhost:3306/epw3, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 83020, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.]
13:36:16,983 [INFO ] [def.DefaultLoadEventListener][onLoad] [Error performing load command]
org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:363)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:122)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:828)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
at net.earthlink.epw3.util.EPW3DaoHelper.findExistingUserAcct(EPW3DaoHelper.java:126)
at net.earthlink.epw3.dao.impl.WriteQueryDAOImpl.saveOrUpdateUserAcct(WriteQueryDAOImpl.java:74)
at test.net.earthlink.epw3.WriteQueryDAOTest.insertTestData1(WriteQueryDAOTest.java:606)
at test.net.earthlink.epw3.WriteQueryDAOTest.insertTestDataForSave(WriteQueryDAOTest.java:598)
at test.net.earthlink.epw3.WriteQueryDAOTest.testSaveUserAcct(WriteQueryDAOTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.sql.SQLException: com.mchange.v2.c3p0.PoolBackedDataSource@83020 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@190d8e1 [ 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 -> 190d8e1, idleConnectionTestPeriod -> 1000, initialPoolSize -> 5, maxIdleTime -> 100, maxPoolSize -> 50, maxStatements -> 400, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@ae97c4 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> ae97c4, jdbcUrl -> jdbc:mysql://localhost:3306/epw3, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 300, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, usesTraditionalReflectiveProxies -> false ], factoryClassLocation -> null, identityToken -> 83020, numHelperThreads -> 3 ] has been closed() -- you can no longer use it.
at com.mchange.v2.c3p0.PoolBackedDataSource.assertCpds(PoolBackedDataSource.java:234)
at com.mchange.v2.c3p0.PoolBackedDataSource.getPoolManager(PoolBackedDataSource.java:246)
at com.mchange.v2.c3p0.PoolBackedDataSource.getConnection(PoolBackedDataSource.java:94)
at org.hibernate.connection.C3P0ConnectionProvider.getConnection(C3P0ConnectionProvider.java:35)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:360)
... 39 more
Please let me know if I need to configure anything else ?