Here is an excerpt from my hibernate.cfg.xml file pertaining to the c3p0 configuration:
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.min_size">10</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">100</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.idle_test_period">1000</property>
In the servlets that I coded, each Hibernate Session is initialized as the following:
Session = HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
... misc. data accessing ...
tx.commit();
session.close();
As an experiment, if I do anything regarding the session after the session.close(); statement, the application throws an error sayaing that the connection has already been closed. Therefore, it seems like the connection is being closed properly but not being returned to the pool.
Here is the output once all of the connections are exhausted:
12:17:53,259 DEBUG [DefaultListableBeanFactory:203] - Returning cached instance of singleton bean '/actions/regLogin'
12:17:53,259 DEBUG [SessionImpl:220] - opened session at timestamp: 4956560888868864
12:17:53,260 DEBUG [JDBCTransaction:54] - begin
When the servlet is hit, the application hangs until the browser detects a TCP timeout.
|