I am using ibatis-sqlmap-2.3.0 version and has requirement to insert around 70K lines in a table.
Using SqlExecutor Batch functionality I also want to know index of statement that failed in middle of executeBatch();
following is the code piece for the same.
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
try {
for (TableRow ar1 : AllRows) {
executor.insert("myRates.insertData", ar1);
}
aBatchList = executor.executeBatchDetailed();
} catch (BatchException e) {
e.printStackTrace();
System.out.println("failing exception " + e.getFailingSqlStatement());
System.out.println("failing statement id " + e.getFailingStatementId());
System.out.println("message exception is " + e.getMessage());
System.out.println(e.getSuccessfulBatchResults());
}
}
Problem: when result of failure comes it gives me the error of duplicate data with message of "om.ibatis.sqlmap.engine.execution.BatchException: Sub batch number 1 failed."
Index 1 is wrong because I know duplicate entries are at some other line.
Reason: I checked the code of this jar , and it consider only single statement consisting of all of my executor.insert("ratesUtil.insertAreaData", ar1);
and hence the index of 1.
Output for your reference :
1) System.out.println("failing exception " + e.getFailingSqlStatement()); --insert into table values (?,?,?) 2)System.out.println("failing statement id " + e.getFailingStatementId()); 3)System.out.println("message exception is " + e.getMessage()); --Sub batch number 1 failed. 4)System.out.println(e.getSuccessfulBatchResults()); -- NULL
Please help me to 1) How can I set these insert queries as multiple batch statement in single executor and execute all these batch statements in single executor.executeBatch();
2) Is there any other way to get correct index of failed statement.
I can't change version as per some problem with project configuration. Also don't want to rely on updateCount as well.