Holdable cursors

Note: Non-holdable cursors are only available in Java 2 Platform, Standard Edition, v 1.4 (J2SE) environments.

The holdable cursor feature permits an application to keep cursors open after implicit or explicit commits. By default, the cursors are held open after a commit. Starting with Java 2 Platform, Standard Edition, v 1.4 (J2SE), cursors can be created with close when a commit occurs option. Such cursors will be automatically closed when a commit happens. Cursors are automatically closed when a transaction aborts, whether or not they have been specified to be held open.

Note: Holdable cursors do not work with XA transactions, in Derby Version 10.1, therefore cursors should be opened with holdability false when working with XA transactions.

To specify whether a cursor should be held open after a commit takes place, supply one of the following ResultSet parameters to the Connection method createStatement, prepareStatement, or prepareCall:

The method Statement.getResultSetHoldability() indicates whether a cursor generated by the Statement object stays open or closes, upon commit. See the Derby Reference Manual for more information.

When an implicit or explicit commit occurs, ResultSets that hold cursors open behave as follows:

When a rollback occurs either explicitly or implicitly, the following behavior applies:

Related concepts
Updatable cursors
ResultSets and auto-commit
Scrolling insensitive ResultSets
Related reference
Simple non-updatable ResultSets