ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: DDL support from Ibatis
Date Wed, 29 Oct 2008 22:17:21 GMT
Getting rid of start/stop won't work, because iBATIS performs "autocommit"
within a transaction still.... :-)

So what you'll need to do is:

session = sqlMapClient.openSession(yourConnectionInAutoCommitMode);
session..... //do work
session.close();

Clinton

On Wed, Oct 29, 2008 at 10:44 AM, Jeff Butler <jeffgbutler@gmail.com> wrote:

> DDL is not "officially" supported in iBATIS - for whatever that's
> worth.  But many people run DDL statements successfully.
>
> The problem seems obvious to me - Sybase does not allow DDL statements
> in transactions (this is true of many other databases also).  So you
> need to get rid of the startTransaction(), commitTransaction() calls.
> Also, I would suggest executing the DDL with the queryForObject()
> method so iBATIS won't wrap a transaction around the call.
>
> Jeff Butler
>
>
>
>
> On Tue, Oct 28, 2008 at 5:37 PM, Sekar, Sowmya <ssekar@ucsd.edu> wrote:
> > Hi,
> >
> > I am trying to rename a table from ibatis.
> >
> >                 Try{
> >
> >             String resource = "sql-map-config.xml";
> >
> >             Reader reader = Resources.getResourceAsReader(resource);
> >
> >             sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
> >
> >             reader.close();
> >
> >
> >
> >             sqlMap.update("table", null);
> >
> >             sqlMap.startTransaction();
> >
> > //code here
> >
> >             sqlMap.commitTransaction();
> >
> >       }
> >
> > Catch(Exception e)
> >
> > {
> >
> > }
> >
> > Finally{
> >
> >       sqlMap.endTransaction();
> >
> > }
> >
> >
> >
> > Sql-map-config.xml :
> >
> > EXEC sp_rename old_table, new_table
> >
> >
> >
> > When I Execute this piece, it throws an exception :
> >
> >
> >
> > --- Cause: com.sybase.jdbc2.jdbc.SybSQLException: Can't run sp_rename
> from
> > within a transaction.
> >
> >
> >
> > What could be the problem?
> >
> > Is DDL supported by Ibatis or not?
> >
> > Sowmya Sekar
> >
> >
>

Mime
View raw message