I am making a request SQL to commit some updates. The updates are done and good, but I would like to know if the batch is executed properly , ie are the statements commited in one go or do the statement excute one after the other ? This is because the autocommit is set implicitly to true, and I wonder if, for the batch to execute as a real "batch", I have to set it to false.
this is a question in relation with this one:
do I need a connection.commit() after executeBatch()?
The code is:
private void pdate(JdbcTemplate jdbcTemplate, List<Long> saisineIdsToUpdate,Connection connection) throws SQLException {
String sqlUpdate = "UPDATE SAISINES SAI WHERE SAI.IDSAISINE = ?"; //request simplified
PreparedStatement psUpdate = connection.prepareStatement(sqlUpdate);
for (Long saisineId : saisineIdsToUpdate) {
psUpdate.setLong(1, saisineId );
psUpdate.addBatch();
}
psUpdate.executeBatch();
psUpdate.close();
}