Good afternoon. Clearly I'm doing something wrong here; hopefully you all can help me.
My standalone java application was running just fine with Hibernate's built-in connection pooling. I then attempted to turn on c3p0 connection pooling, but the SessionFactory.openSession() method is blocking. As I understand it, all I need to do is add a few lines to my hibernate.cfg.xml file. So I've added the following lines:
Code:
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">5</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
Just in case any existing properties might conflict with the c3p0 configuration, here is my hibernate.cfg.xml in full:
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.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">600</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
<mapping resource="a/b/c/SomeEntity.hbm.xml" />
...
more mappings
...
</session-factory>
</hibernate-configuration>
The JDBC connection properties are loaded from a properties file and added to the Configuration object before Configuration.buildSessionFactory() is called. I would wonder if the programmatic setting of the JDBC connection properties conflicted with the hibernate.cfg.xml properties, however I know that it's still loading and processing the XML because it still performs all the mapping functions.
No exceptions are being thrown or anything like that; the SessionFactory.openSession() method just spins. What might I be missing?
Thanks for your help.