Configuring c3p0 with Hibernate for Spring\Tomcat\JTA

View: New views
1 Messages — Rating Filter:   Alert me  

Configuring c3p0 with Hibernate for Spring\Tomcat\JTA

by gersav :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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,

<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,

<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.properteis file with,

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?