title: How to handle bad or duplicate records in Statement.ExecuteBatch()
body: <p>I have a java program which processes a file of 1 Million records and insert it into a table using bulk insertion i.e. <code>Statement.addbatch()</code> and then <code>Statement.executeBatch()</code> after every 1000 records. The program runs quite fast.</p>
  
  <p>However, if there is a duplicate record i.e. the table raises an exception the whole batch is gone and the rest of the records are un-trackable.</p>
  
  <p>Even if I get the <code>updatecount()</code> is is of no help because I cannot insert the duplicates into another table etc.</p>
  
  <p>Is there a way, that in 1 particular batch insert of 1000, if there is a bad record, then each record in that batch can be processed 1 by 1 so that the bad/duplicate records can be placed in another table and the non-duplicates in regular table ?</p>
  
  <p>Is there any other class I can use ? I know in c++ the Oracle provides OCI which can handle single records in the batch (called Host array operation), but in Java the Bulk insertion is usually done by <code>Statement.adding</code> in the loop and then inserting it using <code>Statement.executeBatch()</code>.</p>
  
  <p>Thanks. </p>