-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: open session is blocking after switch to c3p0
PostPosted: Wed May 27, 2009 5:12 pm 
Newbie

Joined: Tue Apr 08, 2008 8:01 pm
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.