• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to find out the culprit row in batch insert?

 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using batch inserts in JDBC to quickly insert rows at a time. I'm making use of prepared statement to bind the parameters.

The problem is I get an exception:



And I can't for the life of me investigate the root cause -- the insert statement which is causing the problem. The relevant part of the codes is pasted:




How do I find out the problem so that I can address it in the face of stack trace pointing to the not-so-helpful executeBatch statement? Printing to the console also was not of help in narrowing down the issue.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ashan,
It isn't obvious from the code which column gives the error. If you know that, you could output just that column and see when it is non-numeric.

Another way to debug, is to change the batch size to 1 so you know exactly which row is failing.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
Java MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to find out the cause. It was the data source (Apache POI skipping the formula cells in my case) that was not providing complete row.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic