You are passing a String object in not a bean and you are using SQL param substitution (using #) but it seems you want to pass in the whole sql text (use $)
Change #sqlString# to $value$ #sqlString# is looking for a field called sqlString on the String object. -----Original Message----- From: Jeff P [mailto:[email protected]] Sent: maandag 26 januari 2009 18:02 To: [email protected] Subject: Create statement used wrongly? 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(Map pedStatement.java:107) at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDe legate.java:393) at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.jav a: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.htm l Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
