ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vijai Senthil Padmanabhan Kalaiyarasi" <vijaisenthil.padmanab...@kumaran.com>
Subject Regd. sessionContext.setRollBackOnly() in EJB with iBATIS (Re: Connection pool mechanism in iBATIS.)
Date Wed, 05 Oct 2005 15:29:08 GMT

    I tried calling two methods (one an insert and the other creating an Oracle Role) of two
different DAO class from a single EJB method.
    And in the catch block i did a sessionContext.setRollBackOnly().

    When the Creating Role gave an error like insufficient privileges, it went to catch block
and executed the setRollBackOnly(). 
    But still the insert operation was not rolled back.

    I think it is taking two different connections for those two operation, because i could
see in the log as below.

    When record insertion
    DEBUG : [HttpRequestHandler-26870275 : com.ibatis.common.jdbc.logging.ConnectionLogProxy.<init>(ConnectionLogProxy.java:39)]
{conn-100367} Connection

    When Role creation
    DEBUG : [HttpRequestHandler-26870275 : com.ibatis.common.jdbc.logging.ConnectionLogProxy.<init>(ConnectionLogProxy.java:39)]
{conn-100371} Connection

    Could anyone guide me how to do that, by considering the above scenario?

Thanks in advance
  ----- Original Message ----- 
  From: Jeff Butler 
  To: user-java@ibatis.apache.org 
  Sent: Friday, September 30, 2005 2:21 PM
  Subject: Re: Connection pool mechanism in iBATIS.

  You have configured iBATIS to NOT use the application server's connection pool - you've
asked iBATIS to use it's own connection pool (DBCP).

  If you mean that you want to call setRollBackOnly() in an EJB method, then this will not
work with your current configuration.  If you want to use EJB's container managed transactions,
you'll need to do the data source lookup from JNDI and configure iBATIS like this: 

    <transactionManager type="EXTERNAL">
      <property name="SetAutoCommitAllowed" value="false"/>
      <dataSource type="JNDI">
        <property name="DataSource" value="java:comp/env/jdbc/hsdb"/> 

  However, I remember from your previous posts that you need to use local credentials to create
the database connection.  If that requirement remains, then you'll have to keep it the way
it is and manage transactions with iBATIS code - rather than letting the container do it for

  For this, and many other, reasons it would be best if you did not have to use local credentials
to connect to your database.  It would be much better to pass the USER as a parameter to the
procedures, rather than relying on the logon credential of the connection. 

  Jeff Butler

  On 9/30/05, Vijai Senthil Padmanabhan Kalaiyarasi <vijaisenthil.padmanabhan@kumaran.com>

        I have a doubt whether the iBATIS will use the connection pool of the Application
server's or its own mechanism.
        Because I need to so a sesionContext.setRollBackOnly()
        My SQLMapConfig for connection info goes like this. 
        I am not using any JNDI look up to the Application server to get the datasource.


    <transactionManager type="JDBC">
        <dataSource type="SIMPLE">
            <property name="JDBC.Driver" value="oracle.jdbc.driver.OracleDriver "/>
            <property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@machname:1521:sid"/>
            <property name="JDBC.Username" value="${ username}"/>
            <property name="JDBC.Password" value="${password}"/>
            <property name="JDBC.DefaultAutoCommit " value="true" />
            <property name="Pool.MaximumActiveConnections" value="10"/>
            <property name="Pool.MaximumIdleConnections" value="5"/> 
            <property name="Pool.MaximumCheckoutTime" value="120000"/>

    Thanks in advance...
    Vijai Senthil P K

View raw message