ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff P <killingd...@hotmail.com>
Subject Create statement used wrongly?
Date Mon, 26 Jan 2009 17:01:47 GMT

I want to feed my client the database/table creation queries. However iBatis
doesnt seem to execute them right. My method looks as the following:

public static void createDatabase(String sqlString) throws SQLException
{
     BaseSqlMapper.sqlMapper.insert("createDatabase", sqlString);
}

Inside my sqlMap i use the following:

<statement id="createDatabase" parameterClass="String">
    #sqlString#
</statement>

The error I get is:

Jan 26, 2009 5:56:32 PM com.cargoxl.start.RootFrame requestDatabaseBuild
SEVERE: null
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/cargoxl/business/data/sql/util_SqlMap.xml.  
--- The error occurred while executing update.  
--- Check the           ?     .  
--- Check the SQL Statement (preparation failed).  
--- Cause: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement          
?[*]     ; SQL statement:
          ?      [42000-101]
        at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
        at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
        at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
        at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.insert(SqlMapClientImpl.java:58)




I've noticed while searching the archive, iBatis doesnt 100% support the
Alter/Create commands. And for the time being I've made a work-arround that
looks like this.

 try
        {
            BaseSqlMapper.sqlMapper.startTransaction();
           
System.out.println(BaseSqlMapper.sqlMapper.getCurrentConnection());
            Statement stmt =
BaseSqlMapper.sqlMapper.getCurrentConnection().createStatement();
            stmt.executeUpdate(sqlString);
            BaseSqlMapper.sqlMapper.commitTransaction();
            stmt.close();
        } 
        finally
        {
            BaseSqlMapper.sqlMapper.endTransaction();
        }


This works fine but I'm not sure if this is the cleanest way to do it.

Thanks.

p.s. sorry for the Bold, was trying to make it better readable
-- 
View this message in context: http://www.nabble.com/Create-statement-used-wrongly--tp21669143p21669143.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Mime
View raw message