You can't rollback after a commit. The commit closes the transaction, so attempting to rollback throws an error.
You don't need to rollback
after the commit
. Rolling back will automatically happen on the server if any of the added statements fails. You only need to call rollback
if your application manually needs to rollback the transaction, which you should do before committing.