0

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.

devnull69
  • 16,402
  • 8
  • 50
  • 61
Amit Sharma
  • 31
  • 1
  • 5
  • Can anyone please help me out for this?I need it little urgent. Though I have already tried to give all information,Let me know if any further detail is required. Thanks. – Amit Sharma Sep 03 '12 at 09:05

1 Answers1

0

You can add multiple batch instead of using one adding all statement in on batch . This will give you idea which lot is giving you issue. but then this not actual answer of your question just

Zuned Ahmed
  • 1,357
  • 6
  • 29
  • 56