You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Vijai Senthil Padmanabhan Kalaiyarasi <vi...@kumaran.com> on 2005/09/30 18:40:04 UTC
Connection pool mechanism in iBATIS.
Hi,
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.
SQLMapconfig.xml
---------------------------
<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"/>
</dataSource>
</transactionManager>
Thanks in advance...
Vijai Senthil P K
Re: Regd. sessionContext.setRollBackOnly() in EJB with iBATIS (Re: Connection pool mechanism in iBATIS.)
Posted by Vijai Senthil Padmanabhan Kalaiyarasi <vi...@kumaran.com>.
Yes...
I have done as you have said.
SQLMapConfig.xml
------------------------------
<transactionManager type="EXTERNAL">
<property name="SetAutoCommitAllowed" value="false"/>
<dataSource type="JNDI">
<property name="DataSource" value="java:comp/env/jdbc/sisds"/>
</dataSource>
</transactionManager>
ejb-jar.xml
----------------
<container-transaction>
<method>
<ejb-name>SISService</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
I beleive, I have done as what you have suggested.
Please let me know if I am wrong anywhere.
Thanks and Regards
Vijai Senthil P K
----- Original Message -----
From: Jeff Butler
To: user-java@ibatis.apache.org
Sent: Wednesday, October 05, 2005 12:06 PM
Subject: Re: Regd. sessionContext.setRollBackOnly() in EJB with iBATIS (Re: Connection pool mechanism in iBATIS.)
Did you configure iBATIS to use an EXTERNAL transaction manager as I suggested? Have you changed your ejb-jar.xml to denote the methods that need transactional support?
Jeff Butler
On 10/5/05, Vijai Senthil Padmanabhan Kalaiyarasi <vi...@kumaran.com> wrote:
Hi,
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
VIJAI SENTHIL P K
----- 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"/>
</dataSource>
</transactionManager>
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 you.
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> wrote:
Hi,
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.
SQLMapconfig.xml
---------------------------
<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"/>
</dataSource>
</transactionManager>
Thanks in advance...
Vijai Senthil P K
Re: Regd. sessionContext.setRollBackOnly() in EJB with iBATIS (Re: Connection pool mechanism in iBATIS.)
Posted by Jeff Butler <je...@gmail.com>.
Did you configure iBATIS to use an EXTERNAL transaction manager as I
suggested? Have you changed your ejb-jar.xml to denote the methods that need
transactional support?
Jeff Butler
On 10/5/05, Vijai Senthil Padmanabhan Kalaiyarasi <
vijaisenthil.padmanabhan@kumaran.com> wrote:
>
> Hi,
> 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
> VIJAI SENTHIL P K
>
> ----- Original Message -----
> *From:* Jeff Butler <je...@gmail.com>
> *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"/>
> </dataSource>
> </transactionManager>
>
> 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 you.
> 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> wrote:
> >
> > Hi,
> > **
> > 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.
> > SQLMapconfig.xml
> > ---------------------------
> > <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"/>
> > </dataSource>
> > </transactionManager>
> > **
> > *Thanks in advance...
> > *Vijai Senthil P K
> >
>
>
Regd. sessionContext.setRollBackOnly() in EJB with iBATIS (Re: Connection pool mechanism in iBATIS.)
Posted by Vijai Senthil Padmanabhan Kalaiyarasi <vi...@kumaran.com>.
Hi,
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
VIJAI SENTHIL P K
----- 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"/>
</dataSource>
</transactionManager>
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 you.
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 <vi...@kumaran.com> wrote:
Hi,
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.
SQLMapconfig.xml
---------------------------
<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"/>
</dataSource>
</transactionManager>
Thanks in advance...
Vijai Senthil P K
Re: Connection pool mechanism in iBATIS.
Posted by Jeff Butler <je...@gmail.com>.
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"/>
</dataSource>
</transactionManager>
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 you.
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> wrote:
>
> Hi,
> **
> 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.
> SQLMapconfig.xml
> ---------------------------
> <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"/>
> </dataSource>
> </transactionManager>
> **
> *Thanks in advance...
> *Vijai Senthil P K
>