Transactions with Savepoints

Since JDBC 3.00.JC2 and Informix server 11.50.xC2, Informix supports SQL transactions that can be rolled back to a Savepoint. A Savepoint is a marker created at any point during a transaction that you can rollback to rather than completely rolling back the entire transaction.

JDBC applications can create, destroy, or rollback to Savepoint objects through the following standard JDBC methods:
Table 1. JDBC Savepoint classes and methods
Class Method
Connection

setSavepoint()

setSavepoint(String name)

releaseSavepoint(Savepoint)

rollback(Savepoint)
Savepoint

getSavepointId()

getSavepointName()

These two methods are not interchangeable. A call to getSavepointName() fails with an error unless the savepoint object is declared with a string argument to the setSavepoint() method or to the setSavepointUnique() method. Similarly, an error is returned if you call getSavepointId() for a named savepoint object.

In addition, the setSavepointUnique(String name) method can set a named savepoint whose identifier is unique. If the application attempts to reuse its name within the same connection JDBC will throw a SQLException.

The following restrictions apply to Savepoint objects in JDBC:
  • Savepoints are not valid within XA transactions.
  • Savepoints cannot be used unless the current connection sets autocommit mode off.
  • Savepoints are not valid in connections to unlogged databases.
  • Savepoints cannot be referenced in a triggered action.
  • In cross-server distributed queries in which any participating subordinate server does not support savepoint objects, a warning is issued if you set a savepoint after connecting to a server that does not support savepoints, and any call to rollbacksavepoint fails with an error.
Form more information, see IBM Informix Guide to SQL: Syntax.