protected void removeMarkersThatWereSuccessful(BatchUpdateException ex) { int[] updateCounts = ex.getUpdateCounts(); Iterator<Object> it = markers.iterator(); int index = 0; while (it.hasNext()) { it.next(); if (updateCounts.length > index && normalizeUpdateCount(updateCounts[index]) > 0) { it.remove(); } index++; } }
public int flush() { int rowsUpdated = 0; if (markers.size() > 0 && pstmt != null) { try { int[] updates = pstmt.executeBatch(); for (int i : updates) { rowsUpdated += normalizeUpdateCount(i); } markers.clear(); } catch (BatchUpdateException ex) { removeMarkersThatWereSuccessful(ex); throw jdbcSqlTemplate.translate(ex); } catch (SQLException ex) { throw jdbcSqlTemplate.translate(ex); } } return rowsUpdated; }