Hi all,

I encountered a
'com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException' while
executing the following SQL script:

   <statement id="create-table" parameterClass="list">
       CREATE TABLE data
           <iterate open="(" close=")" conjunction=",">
               $[].name$ $[].type$
           </iterate>
   </statement>

The java code that prepare the list parameter and execute the SQL script is as follow:

   ...
   sqlMapClient.startTransaction();
   sqlMapClient.update("create-table", prepareCreateTableParams());
   sqlMapClient.commitTransaction();
   ...

   private List<Map<String, String>> prepareCreateTableParams(
           final String[] columnNames, final String[] columnTypes) {
       List<Map<String, String>> params =
           new ArrayList<Map<String, String>>();
       for(int i = 0; i < columnNames.length; i++) {
           HashMap<String, String> map = new HashMap<String, String>();
           map.put("name", columnNames[i]);
           map.put("type", columnTypes[i]);
           params.add(map);
       }
       return params;
   }

and the exception is:

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the create-seqnsdata-table-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near '
,          ,          ,          ,          ,          ,          ,   '
at line 1
   at
com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
   at
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.update(SqlMapExecutorDelegate.java:457)
   at
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.update(SqlMapSessionImpl.java:90)
   at
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.update(SqlMapClientImpl.java:66)
   at net.eads.iw.seqns.CsvJdbcInjector.inject(CsvJdbcInjector.java:117)
   ... 1 more

Obviously, iBatis is not correctly replacing $[].name$ and $[].type$ by
the value supplied in the list of map of string, string.
Do I have my iBatis-SQL script wrong or do iBatis is not doing its job
right ?

Tanks in advance.




Reply via email to