SYMPTOM

 When trying to load data inside an HSQL database, the following error is thrown:

 java.sql.SQLException: statement is not in batch mode
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    at org.hsqldb.jdbc.JDBCUtil.sqlExceptionSQL(Unknown Source)
    at org.hsqldb.jdbc.JDBCPreparedStatement.executeBatch(Unknown Source)
    at com.indy.engine.actionCodes.jdbc.SimpleJdbcActionCodeTypeI$WrappedPreparedStatement.executeBatch(SimpleJdbcActionCodeTypeI.java:298)
    at com.indy.engine.actionCodes.jdbc.SimpleJdbcActionCodeTypeI.finalizeStatement(SimpleJdbcActionCodeTypeI.java:349)
    at com.indy.engine.actionCodes.XmlToJdbcActionCodeI.finalizeExecuteCode(XmlToJdbcActionCodeI.java:301)
    at com.indy.engine.action.common.ActionCodeTypeI.finalizeExecuteCode(ActionCodeTypeI.java:266)
    at com.indy.engine.manager.ActionCodeExecutor.executeCode(ActionCodeExecutor.java:149)
    at com.indy.engine.manager.ActionCodeExecutor.run(ActionCodeExecutor.java:268)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.hsqldb.HsqlException: statement is not in batch mode
    at org.hsqldb.error.Error.error(Unknown Source)
    at org.hsqldb.error.Error.error(Unknown Source)
    ... 9 more

 

Most notably, we detected that this may happen when doing a Mapping loading a source XML File into a target HSQL database, but it might also appear in other situations when loading data into HSQL.

 

 

 

SOLUTION

 

When loading data on a target column which has a too small size comparing to data we want to write, the HSQL JDBC driver might throw this unclear error message.

This generic exception might be returned by the HSQL Driver if you are trying to load data in an HSQL target column which size is too small comparing to data that is written.

Make sure that the target columns sizes are correct and are large enough to handle the data you are trying to write into.

 

Note that in some situations, the HSQL driver might throw a clearer message such as java.sql.SQLDataException: data exception: string data, right truncation) when this happens.

But it depends on the context, sometimes the generic java.sql.SQLException: statement is not in batch mode message is thrown in this situation.