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 Tom Henricksen <To...@A-t-g.com> on 2007/05/09 15:40:10 UTC

Trying to use iBatis's connection

We are adding some non iBatis code and trying to tap in to the iBatis
connection for some code analysis purposes.  This works when we run our
code but through builds unit test we get an exception.  Here is some
code examples:

 

Connection connection = mapSession.getCurrentConnection();

 

if (connection == null) {

            mapSession.startTransaction();

            startedTransaction = true;

}

 

            // SAVE SOME things.

 

            if (startedTransaction) {

                                                connection =
mapSession.getCurrentConnection();

                                                connection.commit();

                                    }

 

                        } finally {

                                    if (startedTransaction && mapSession
!= null) {

 
mapSession.endTransaction();

                                                mapSession.close();

                                                mapSession = null;

                                                connection.close();

                                                connection = null;

                                    }

                        }

 

This is the exceptions we get from our unit tests:

 

: com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -805,
SQLSTATE: 51002, SQLERRMC: NULLID.SYSLH203 0X5359534C564C3031  at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:180)  at
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForList(GeneralStatement.java:118)  at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMap
ExecutorDelegate.java:610) 

 

I realize this is kind of a kludge.  I am guessing this isn't
recommended use?  Would you suggest getting our own connection outside
of iBatis?  Is it possible to pull the connection string info (username
and password, etc) out of the iBatis connection?

 

Thanks,

Tom

 


Re: DaoManager Transaction problem

Posted by "ohsuria@gmail.com" <oh...@gmail.com>.
oh.. got it.
I used MyISAM.

I should use InnoDB if I want to use transaction.

Thank you so much Larry.  :)

On Thursday 10 May 2007 22:37, Larry Meadors wrote:
> InooDB or MyISAM?
>
> Larry
>
> On 5/10/07, ohsuria@gmail.com <oh...@gmail.com> wrote:
> > Yes It is MySQL.
> >
> > On Thursday 10 May 2007 21:28, Larry Meadors wrote:
> > > Is it MySQL?
> > >
> > > Larry

Re: DaoManager Transaction problem

Posted by Larry Meadors <lm...@apache.org>.
InooDB or MyISAM?

Larry


On 5/10/07, ohsuria@gmail.com <oh...@gmail.com> wrote:
> Yes It is MySQL.
>
> On Thursday 10 May 2007 21:28, Larry Meadors wrote:
> > Is it MySQL?
> >
> > Larry
> >
>

Re: DaoManager Transaction problem

Posted by "ohsuria@gmail.com" <oh...@gmail.com>.
Yes It is MySQL.

On Thursday 10 May 2007 21:28, Larry Meadors wrote:
> Is it MySQL?
>
> Larry
>

Re: DaoManager Transaction problem

Posted by Larry Meadors <lm...@apache.org>.
Is it MySQL?

Larry


On 5/10/07, ohsuria@gmail.com <oh...@gmail.com> wrote:
> Dear Experts,
>
> I am trying to use Transaction with iBatis DaoManager.
> I need to make sure all deletion must be completed or the transaction should
> be roll-backed.
>
> Here is my bean:
> ---------------------------------------------------------------------------
>       public void deleteF0002(List p_listF0002) {
>             try {
>                   F0002 objF0002;
>
>                   daoManager.startTransaction();
>                   if (p_listF0002.size() > 0) {
>                         for (int i = 0; i < p_listF0002.size(); i++) {
>                               objF0002 = (F0002) p_listF0002.get(i);
>                               objF0002DAO.deleteByPrimaryKey(objF0002.getCityid());
>                         }
>                   }
>                   //daoManager.commitTransaction();
>             } finally {
>                   daoManager.endTransaction();
>             }
>
>       }
> ---------------------------------------------------------------------------
>
> I remark the commitTransaction() just for testing purpose..
> I thought the deletion process will be roll-backed, since the
> commitTransaction() is not triggered.
> Well I am wrong.. it still deletes records.
>
> Can anyone help me on this? why the transaction doesn't roll-backed?
>
> Thanks in advance.
>

DaoManager Transaction problem

Posted by "ohsuria@gmail.com" <oh...@gmail.com>.
Dear Experts,

I am trying to use Transaction with iBatis DaoManager.
I need to make sure all deletion must be completed or the transaction should 
be roll-backed.

Here is my bean:
---------------------------------------------------------------------------
      public void deleteF0002(List p_listF0002) {
            try {
                  F0002 objF0002;

                  daoManager.startTransaction();
                  if (p_listF0002.size() > 0) {
                        for (int i = 0; i < p_listF0002.size(); i++) {
                              objF0002 = (F0002) p_listF0002.get(i);
			      objF0002DAO.deleteByPrimaryKey(objF0002.getCityid());
                        }
                  }
                  //daoManager.commitTransaction();
            } finally {
                  daoManager.endTransaction();
            }

      }
---------------------------------------------------------------------------

I remark the commitTransaction() just for testing purpose..
I thought the deletion process will be roll-backed, since the 
commitTransaction() is not triggered.
Well I am wrong.. it still deletes records.

Can anyone help me on this? why the transaction doesn't roll-backed?

Thanks in advance.

Re: Trying to use iBatis's connection

Posted by Jeff Butler <je...@gmail.com>.
This error doesn't seem to be related to iBATIS.  See here:

http://www-1.ibm.com/support/docview.wss?uid=swg21208123

Jeff Butler


On 5/9/07, Tom Henricksen <To...@a-t-g.com> wrote:
>
>  We are adding some non iBatis code and trying to tap in to the iBatis
> connection for some code analysis purposes.  This works when we run our code
> but through builds unit test we get an exception.  Here is some code
> examples:
>
>
>
> Connection connection = mapSession.getCurrentConnection();
>
>
>
> if (connection == null) {
>
>             mapSession.startTransaction();
>
>             startedTransaction = true;
>
> }
>
>
>
>             // SAVE SOME things.
>
>
>
>             if (startedTransaction) {
>
>                                                 connection =
> mapSession.getCurrentConnection();
>
>                                                 connection.commit();
>
>                                     }
>
>
>
>                         } finally {
>
>                                     if (startedTransaction && mapSession
> != null) {
>
>                                                 mapSession.endTransaction
> ();
>
>                                                 mapSession.close();
>
>                                                 mapSession = null;
>
>                                                 connection.close();
>
>                                                 connection = null;
>
>                                     }
>
>                         }
>
>
>
> This is the exceptions we get from our unit tests:
>
>
>
> : com.ibm.db2.jcc.a.SqlException: DB2 SQL error: SQLCODE: -805, SQLSTATE:
> 51002, SQLERRMC: NULLID.SYSLH203 0X5359534C564C3031  at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback
> (GeneralStatement.java:180)  at
> com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList
> (GeneralStatement.java:118)  at
> com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(
> SqlMapExecutorDelegate.java:610)
>
>
>
> I realize this is kind of a kludge.  I am guessing this isn't recommended
> use?  Would you suggest getting our own connection outside of iBatis?  Is it
> possible to pull the connection string info (username and password, etc) out
> of the iBatis connection?
>
>
>
> Thanks,
>
> Tom
>
>
>