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.

3 comments:

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

    ReplyDelete
  2. You are probably an expert in this field, I just recently began to study the topic of programming. It turned out to be not so complicated. But still this deal requires patience and attention. For me, I found a good informative blog, which reveals the whole point about how to split a string in java https://explainjava.com/split-string-java/. It really helped me. Information on the Internet is too much, among the garbage, I managed to find a really valuable manuscript.

    ReplyDelete