-->
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: Configuring Hibernate with c3p0 in JTA\Tomcat environment
PostPosted: Tue Apr 07, 2009 8:45 am 
Newbie

Joined: Tue Apr 07, 2009 8:41 am
Posts: 1
I am trying to use C3p0 with Hibernate 3.2.5, Spring 2.5.1, Tomcat 6.0.16 & using JOTM for JTA support

I've tried to follow the various guidance on configuring c3p0 with Hibernate but when I debug into Hibernate, I se that the InjectedDataSourceConnectionProvider is being ceated and used instead of C3P0ConnectionProvider.

Here is a summary of my configuration settings,

In tomcat I have a set of JNDI resources configures like,

Code:
<Resource name="jdbc/test-dataSource" auth="Container" type="javax.sql.XADataSource"
              factory="org.objectweb.jndi.DataSourceFactory"
              driverClassName="net.sourceforge.jtds.jdbc.Driver" username="sa" password="sa" 
              url="jdbc:jtds:sqlserver://dbServer/testDB" defaultAutoCommit="false" removeAbandoned="true"
              removeAbandonedTimeout="60" logAbandoned="true"/>




I have a corresponding set of hibernate.cfg.xml files for each conenction, like,

Code:
hibernate-configuration>
    <session-factory>
        <property name="connection.datasource">java:comp/env/jdbc/test-dataSource</property>
       
        <property name="jta.UserTransaction">java:comp/UserTransaction</property>
        <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
        <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JOTMTransactionManagerLookup</property>

        <property name="hibernate.current_session_context_class">jta</property>
        <property name="hibernate.cglib.use_reflection_optimizer">true</property>
        <property name="hibernate.transaction.flush_before_completion">true</property>

        <property name="hibernate.connection.release_mode" >auto</property>
       
      <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
       <property name="c3p0.max_size">100</property>
       <property name="c3p0.idle_test_period">300</property> 
      
      ....


and a c3p0.properties file with,

Code:
c3p0.preferredTestQuery="select count(*) from dbo.sysobjects"
c3p0.testConnectionOnCheckin=true
c3p0.acquireRetryAttempts=0
c3p0.acquireRetryDelay=2000
c3p0.maxIdleTime=1800
c3p0.maxStatementsPerConnection=20
c3p0.idleConnectionPeriod=600



I would have expected the "hibernate.connection.provider_class" setting to force hibernate to pick up the c3p0 db pool, but it obvisouly is not. Can anyone give me some indication on where I may be going wrong?


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.