Java tutorial
//package com.java2s; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.HashSet; public class Main { public static void execute_crop_stmt(PreparedStatement pstmt, int[] indexes, HashSet<Integer> set) throws SQLException { int cnt = 0; for (int i = 0; i < indexes.length; i++) { if (!set.contains(indexes[i])) { pstmt.setInt(1, indexes[i]); pstmt.addBatch(); cnt++; if (cnt > 5000) { pstmt.executeBatch(); cnt = 0; } } } if (cnt > 0) pstmt.executeBatch(); } }