Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exceptions in Batch Update process.

Bhasker Reddy
Ranch Hand
Posts: 176
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am inserting millions of records using Batch update process. I mean preparedStatement and executeBatch method. for ex. when I insert 100000 records, sometimes some records fail to get inserted because the data doesn't match correctly to columns in the table. I want to capture this data into an exception table. But how do I know what was the sql error that caused it.
If I am not using executeBatch Method. It tells what sql exception it was. But How do I capture it in Batch process.
int[] updateCounts = preparedstatment.executeBatch();
updateCounts only has -2 or -3 based on success and failure of insert. How do I know what is the reason for the failure, what SQLException it has.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!