• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Is there a way of knowing which record failed in Batch Insert

 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear All

Inside a loop I am setting the input parameters of prepared statement to be inserted ane suppose it fails due to a rason that input value is too large for a colmn for some record in an iteration i.
Since i already has reached the threshold value when I am executing a batch so I seem to have lost which culprit record at which iteration caused it
PreparedStatement doesn't seem to have any clue on finding this
Does any one of you have faced similar situation and know of any crack ?

Thanks in advance
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might help if you can give code snippet. It's not clear what you were doing with the description. Anyway
- Is the loop used to construct the statement and added to a batch to be executed through executeBatch()? If not what do you meant by crossed the threshold?
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sort of confused... a crack for what? A crack is a program or process that makes crippled software into fully functioning software, so I don't see how that pertains to your situation.(At least that's what I always thought it meant).

You could do several different things. One, you could check the data for size before it gets inserted into the prepared statement. Or you could dump your data into a comma delimited file and insert the data from the sql command line.
 
Gaurav Chikara
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using executeBatch and by threshold I meant the size of collection (which I am passing ott his function)
I get the input paremeters from the dataObject of this collection and set them as setters of preparedstatement which I have created before loop

Code snippet is very huge but this is what I am doing (In a nutshell)
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you look at the executeBatch() api description, the return type is int array with the status code of the each statement executed (the order in which it's added to the batch). It should be fairly easy to identify the statement that failed (unless the driver you use doesn't support this feature).

Take a look at the executeBatch() api description let us know if it doesn't work.
 
reply
    Bookmark Topic Watch Topic
  • New Topic