1 Reply Latest reply on Apr 23, 2007 9:02 AM by weston.price

    c3p0 connection not being involved in business transaction?

    swiety

      I am using JBoss4 with c3p0 datasources connecting to MySQL 5 DB. I
      have recently realised that all c3p0 connections are not managed by
      business transaction. So if in my SessionBean I'm obtaining c3p0 DS
      connection (by lookup in JNDI) and then calling setRollbackOnly() on
      this session context, the DB transaction is not being rolled back.
      I am very surprised - when I replace this DS with standard
      local-tx-datasource it works perfectly - by calling
      ctx.setRollbackOnly() DB transaction is being rolled back.

      Cannot find any way to specify which transaction manager c3p0 should
      use. And actually I believe described behaviour doesn't conform to
      J2EE 1.4 spec - specification says that every JDBC connection obtained
      from JNDI inside business transaction should be controlled by this
      transaction.

      Can you help me? Is C3P0 capable of joining the business transaction?

      Configuration of C3P0 DS I'm using is:

      <server>
       <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource"
       name="XXX:service=XXXPooledDataSource">
      
       <attribute name="JndiName">java:XXXDS</attribute>
       <attribute name="JdbcUrl">jdbc:mysql://localhost:3306/dbXXX</attribute>
       <attribute name="DriverClass">com.mysql.jdbc.Driver</attribute>
       <attribute name="User">XXX</attribute>
       <attribute name="Password">XXX</attribute>
       <attribute name="AcquireIncrement">1</attribute>
       <attribute name="AcquireRetryAttempts">30</attribute>
       <attribute name="AcquireRetryDelay">1000</attribute>
       <attribute name="AutoCommitOnClose">false</attribute>
       <attribute name="AutomaticTestTable"></attribute>
       <attribute name="BreakAfterAcquireFailure">false</attribute>
       <attribute name="CheckoutTimeout">0</attribute>
       <attribute name="Description">XXX</attribute>
       <attribute name="FactoryClassLocation"></attribute>
       <attribute name="ForceIgnoreUnresolvedTransactions">false</attribute>
       <attribute name="IdleConnectionTestPeriod">60</attribute>
       <attribute name="InitialPoolSize">1</attribute>
       <attribute name="MaxIdleTime">60</attribute>
       <attribute name="MaxPoolSize">3</attribute>
       <attribute name="MaxStatements">0</attribute>
       <attribute name="MaxStatementsPerConnection">0</attribute>
       <attribute name="MinPoolSize">0</attribute>
       <attribute name="NumHelperThreads">3</attribute>
       <attribute name="PreferredTestQuery"></attribute>
       <attribute name="TestConnectionOnCheckin">true</attribute>
       <attribute name="TestConnectionOnCheckout">false</attribute>
       <attribute name="UsesTraditionalReflectiveProxies">false</attribute>
       <depends>jboss:service=Naming</depends>
       </mbean>
      </server>