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 "Broderick, Andrew (GE Indust, ES Rail, consultant)" <an...@ge.com> on 2007/08/08 00:11:05 UTC

iBATIS & DB connections

Hi,

I am using iBATIS 2.3 with Spring 2 and Oracle 10g. I have a few questions:

-Does iBATIS get a new Connection for each query and then close it again afterwards? 
-Is it different for select vs insert or update? 
-Does it depend on whether a transaction is open?

Thanks,

Andrew B

Re: iBATIS & DB connections

Posted by Clinton Begin <cl...@gmail.com>.
>> Does iBATIS get a new Connection for each query and then close it again
afterwards?

This totally depends on the connection pool you're using.  Since you're
using Spring, it's totally up to whichever connection pool spring is using.

>> Is it different for select vs insert or update?

Normally no, save for your next question....

>> Does it depend on whether a transaction is open?

Yes.  If a transaction is open, it will reuse the same connection (within a
transaction scope) for all statements (be it insert or select) within that
scope.

If a transaction is not open, every single statement you call (be it insert
or select) will request a separate connection (which may in fact be the same
depending on the pool).

Cheers,
Clinton

On 8/7/07, Broderick, Andrew (GE Indust, ES Rail, consultant) <
andrew.broderick@ge.com> wrote:
>
> Hi,
>
> I am using iBATIS 2.3 with Spring 2 and Oracle 10g. I have a few
> questions:
>
> -Does iBATIS get a new Connection for each query and then close it again
> afterwards?
> -Is it different for select vs insert or update?
> -Does it depend on whether a transaction is open?
>
> Thanks,
>
> Andrew B
>