ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Re: Managing session opened with external connection
Date Thu, 09 Feb 2006 16:38:19 GMT
When using openSession(...) you must also closeSession(). If you look
at the SqlMapClient javadoc you will see information regarding
openSession(). http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/src/com/ibatis/sqlmap/client/SqlMapClient.java

Brandon

On 2/9/06, Joel Costigliola <joel.costigliola@steria.com> wrote:
>
> Thanks Brandon !
>
> Do you think it's important to close the session even if connection is
> managed externally ?
>
> ---- Messages d´origine ----
> De: Brandon Goodin <brandon.goodin@gmail.com>
> Date: jeudi, février 9, 2006 4:24 pm
> Objet: Re: Managing session opened with external connection
>
> > If you are handling your connections externally, it is your job to
> > clean them up.
> >
> > On 2/9/06, Joel Costigliola <joel.costigliola@steria.com> wrote:
> > >
> > > After some code investigation, I think that connection injected into
> > > session - with openSession(myConnection) - are not released when
> > session> is closed.
> > >
> > > Can anyone confirm that ? it's quite important for me to be sure
> > of that
> > > point to convince people at my work to use iBatis.
> > >
> > > I think closing the session is important but it is still not
> > clear what
> > > is done when session is closed.
> > > Where can I have some explanation about session closing mecanism ?
> > >
> > > Thanks for your help
> > >
> > > Joe
> > >
> > > ---- Messages d´origine ----
> > > De: Joel Costigliola <joel.costigliola@steria.com>
> > > Date: mercredi, février 8, 2006 11:26 am
> > > Objet: Managing session opened with external connection
> > >
> > > > Hi all,
> > > >
> > > > I would like to use iBatis on my project. I have some
> > constraints :
> > > > - I need to use a connection management mecanism external to
> > iBatis.> > - I need to use a transactionnal mecanism external to
> > iBatis (not EJB
> > > > but another one).
> > > >
> > > > Following the javadoc example I have successfully inserted an
> > > > object in
> > > > database but I'm wondering if the javadoc example is relevant for
> > > > releasing resources.
> > > >
> > > > - do we have to close the session opened with an external
> > > > connection ?
> > > >
> > > > - if we close the session what will happen for the underlying
> > > > connection ?
> > > >  is it closed ? (I would prefer not as connection is managed
> > > > externally !)
> > > >
> > > > here's the code sample from the javadoc of
> > SqlMapClient.openSession> > (Connection)
> > > >  try {
> > > >     Connection connection = dataSource.getConnection();
> > > >     SqlMapSession session = sqlMap.openSession(connection);
> > > >     // do work
> > > >     connection.commit();
> > > >   } catch (SQLException e) {
> > > >       try {
> > > >         if (connection != null) commit.rollback();
> > > >       } catch (SQLException ignored) {
> > > >         // generally ignored
> > > >       }
> > > >       throw e;  // rethrow the exception
> > > >   } finally {
> > > >     try {
> > > >       if (connection != null) connection.close();
> > > >     } catch (SQLException ignored) {
> > > >       // generally ignored
> > > >     }
> > > >  }
> > > >
> > > > by the way there is a typo mistake --> commit.rollback();
> > instead of
> > > > connection.rollback();
> > > >
> > > > Thanks for your advices !
> > > >
> > > > Joe
> > > >
> > > >
> > > >
> > > >
> > >
> >
> >
>

Mime
View raw message