I am doing a batch update into my DB table using NamedParameterJdbcTemplate.batchUpdate, but I would like to disable auto-commit and perform the commit manually.
I can set auto-commit mode off from the connection object, but not sure how to do the same using NamedParameterJdbcTemplate object.
I have done my implementation using TransactionTemplate
It has an execute method and I do the business logic inside a callback in this function.
transTemplate.execute( new TransactionCallbackWithoutResult()
{
@Override
protected void doInTransactionWithoutResult( TransactionStatus status)
{
status.setRollbackOnly();
//business logic
}
});
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