The answer is: yes you have to call commit.
The "prepare" step does not do anything that is relevant for transaction handling on the server.
You have to call executeUpdate()
(or execute()
) to start a transaction (assuming the used SQL does in fact start a transaction)
Using a PreparedStatement without auto-commit requires the following steps:
- Prepare the statement
- Set the parameter values
- call
executeUpdate()
(or execute()
depending on the type of statement)
- call
Connection.commit()
To make things clearer: calling prepareStatement()
does not require a commit()
.