Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Batch processing help

 
Sean Chang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

I am doing some batch insertions into a database using JDBC, this is more of a question of help with logic then actual JDBC code. I am looping through a list of files to insert into the DB using a prepared statement, i'd like to do a batch insert every 5000 records processed. What I am having trouble with is inserting the remainder of the 5000 interval. For example, if I have 5010 records to insert, it will insert the 5000, but how do I get the 10 additional inserted, I'd like a clean solution, any suggestions would help thanks!

Here is a sample of the code:
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Welcome to Javaranch

Sean,

I did not consider anything other than the logic part. may be check for the last time the loop is executed and force the flow to do the batch update()

say you store int listSize = fileList.size()

Like
>

Edit : added Welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic