How to get how many rows updated with PreparedStatement?
.getUpdateCount() returns 0.
For executeUpdate got error:
error occurred during batching: batch must be either executed or cleared
my code:
updTrans = dataSource.getConnection().prepareStatement("update...");
updTrans.setInt(1, Integer.valueOf(transaksjonstatusid));
...
updTrans.addBatch();
upd = updTrans.executeUpdate();
                You should be using PreparedStatement#executeBatch() when using batches.
...
updTrans.addBatch();
upd = updTrans.executeBatch();
It returns an int[] containing update counts of each batch.
Did you try to use:
int n = preparedStatement.executeUpdate();
Here you can find some explanations on how to use a PreparedStatement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With