Hi,
I am facing two problems:
Problem 1: My c3p0 pool seems to be initialized twice when i start my tomcat service. I am using hibernate in a webapp. Specifically I see the "Initializing c3p0 pool .... " in the tomcat log
twice at the startup of my tomcat service which loads my webapp. This has lead me to believe that c3p0 is being initialized twice. Does anyone have any idea as to why this might be happening and how do I rectify this if this is a problem?
(Note: I have no other webapp deployed in my tomcat webapps directory that uses Hibernate.)
Code:
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@1fe8ce8 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@6ed322 [ acquireIncrement -> 3, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, maxIdleTime -> 0, maxPoolSize -> 15, maxStatements -> 0, minPoolSize -> 3, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@d4d66b [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost/test3, properties -> {user=xyz, password=password} ] , propertyCycle -> 300, testConnectionOnCheckout -> false ] , factoryClassLocation -> null, numHelperThreads -> 3 ]
Problem 2: Once started I have no issues with the execution of my webapp. I use Hibernate in my webapplication. The problem occurs after the webapp is live on the server for an extended amount of time with no activity. I get an exception. I suspect that this might be due to my connections in the connection pool getting timed out or closing. Any ideas as to why thid might be happening?
Exception:
Code:
java.lang.RuntimeException: org.hibernate.exception.GenericJDBCException: Cannot open connection
com.ac.tan.persistence.daos.HBGenericDAO.findOneByQuery(HBGenericDAO.java:282)
com.ac.tan.persistence.daos.HBCartDAO.getCartId(HBCartDAO.java:33)
com.ac.tan.managers.ShoppingManagerImpl.getCartId(ShoppingManagerImpl.java:25)
com.ac.tan.web.filters.CookieFilter.getCartId(CookieFilter.java:82)
com.ac.tan.web.filters.CookieFilter.doFilter(CookieFilter.java:48)
com.ac.tan.web.filters.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:31)
Hibernate version: 3.0
C3p0 version: c3p0-0.8.4.5.jar
Mapping document: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>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/test3</property>
<property name="hibernate.connection.username">xyz</property>
<property name="hibernate.connection.password">password</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- c3p0 connection pool settings -->
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.max_size">15</property>
<property name="hibernate.c3p0.min_size">3</property>
<mapping resource="com/ac/tan/beans/Beans.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Name and version of the database you are using: MySQL 4.1