You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Greg Jackman <Gr...@nycity.com> on 2006/12/13 22:09:15 UTC

Multiple simultaneous connections and transactions

I am successfully using the iBatis Data Mapper, and am not trying to
build that up and use the iBatis Data Access with it as well. However, I
seem to have hit a problem and I was just trying to find out if I am
missing something or if this really is the case...

 

My problem is that I don't seem to be able to open multiple connections
to a single database.

 

The following code throws an exception on the second call to
OpenConnection.

 

            DomDaoManagerBuilder builder = new DomDaoManagerBuilder();

            builder.Configure();

 

            IDaoManager daoManager1 =
DaoManager.GetInstance("SqlMapDao");

            IDaoManager daoManager2 =
DaoManager.GetInstance("SqlMapDao");

 

            IDalSession session1 = daoManager1.GetDaoSession();

            session1.OpenConnection();

 

            IDalSession session2 = daoManager2.GetDaoSession();

            session2.OpenConnection();

 

 

Whilst I appreciate this test is not a real life situation, this
situation will easily occur in a multi-threaded application server which
I am trying to implement.

 

Any thoughts, ideas, suggestions would be greatly appreciated.

 

Many thanks,

Greg Jackman

 

 


Re: Multiple simultaneous connections and transactions

Posted by Gilles Bayon <ib...@gmail.com>.
daoManager1 and daoManager2 are the same instance and there could only once
transaction/connection oopen in a "thread" context.

On 12/13/06, Greg Jackman <Gr...@nycity.com> wrote:
>
>  I am successfully using the iBatis Data Mapper, and am not trying to
> build that up and use the iBatis Data Access with it as well. However, I
> seem to have hit a problem and I was just trying to find out if I am missing
> something or if this really is the caseā€¦
>
>
>
> My problem is that I don't seem to be able to open multiple connections to
> a single database.
>
>
>
> The following code throws an exception on the second call to
> OpenConnection.
>
>
>
>             DomDaoManagerBuilder builder = new DomDaoManagerBuilder();
>
>             builder.Configure();
>
>
>
>             IDaoManager daoManager1 = DaoManager.GetInstance("SqlMapDao");
>
>             IDaoManager daoManager2 = DaoManager.GetInstance("SqlMapDao");
>
>
>
>             IDalSession session1 = daoManager1.GetDaoSession();
>
>             session1.OpenConnection();
>
>
>
>             IDalSession session2 = daoManager2.GetDaoSession();
>
>             session2.OpenConnection();
>
>
>
>
>
> Whilst I appreciate this test is not a real life situation, this situation
> will easily occur in a multi-threaded application server which I am trying
> to implement.
>
>
>
> Any thoughts, ideas, suggestions would be greatly appreciated.
>
>
>
> Many thanks,
>
> Greg Jackman
>
>
>
>
>



-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>