Friday, January 3, 2014

Split a Java List Into a List of Sublists

Often times I'm updating a large amount of records with a batch SQL script, and a lot of times I run into this error: DataIntegrityViolationException: Prepared or callable statement has more than 2000 parameter.

So to help me to update with only the allowed number of parameters I've created a method that will split a List of objects into sublists based on the max number of records you want.  And then I would pass each sublist to the batch update method.

1 comment:

  1. nice example and visit http://www.javaproficiency.com/2015/05/java-arraylist-examples.html

    ReplyDelete