Savepoint support

Adds the Savepoint interface, which contains methods to set, release, or roll back a transaction to designated savepoints.

Using Savepoints in your transactions

The transaction support in JDBC 2.0 allowed you to have control over a transaction and roll back every change in a transaction. In JDBC 3.0, you are given more control with savepoints: the Savepoint interface allows you to partition a transaction into logical breakpoints, providing control over how much of the transaction gets rolled back.

Setting and rolling back to a Savepoint

The JDBC 3.0 API adds the method Connection.setSavepoint, which sets a savepoint within the current transaction and returns a Savepoint object. The Connection.rollback method is overloaded to take a Savepoint object argument.

Releasing a Savepoint

The Connection.releaseSavepoint method takes a Savepoint object as a parameter and removes it from the current transaction. After a Savepoint has been released, if you try to reference it in a rollback operation, a SQLException occurs.Any savepoints that you create in a transaction are automatically released and become invalid when the transaction is committed or when the entire transaction is rolled back. If you roll a transaction back to a savepoint, it automatically releases and invalidates any other savepoints that were created after the savepoint in question.

NoteYou can use the DatabaseMetaData.supportsSavepoints method to determine whether a JDBC API implementation supports savepoints.