ResultSet Shelf Life
A ResultSet behaves differently depending on whether the autocommit property is set on or off.
- If auto-commit is on
-
-
You are limited to one active, valid
ResultSet. -
Associated
ResultSetMetaDataobjects, andResultSetobjects returned fromStatement.getGeneratedKeys()can also be open at the same time but have the same "shelf life" - they are valid until closed, committed, or another statement is executed by theStatementobject. -
A
Statementthat returns aResultSetdefers committing the transaction, so iteration over theResultSetis consistent with the data and the transaction isolation level. -
Each execution of a
Statementwill commit any previously deferred transaction and so closes any associatedResultSet.
-
- If auto-commit is off
-
-
You can have as many
ResultSetobjects as you need, provided eachResultSetcomes from a uniqueStatementinstance. -
You cannot have multiple open
ResultSetobjects from the sameStatement.-
When a
Statementis executed, any currently associatedResultSetis closed and cannot be reopened or reused in any way.
-
-