Contents | Prev | Next | JDBCTM Guide: Getting Started |
Connection.isClosed()
method is only guaranteed to return true after Connection.closed()
has been called. Connection.isClosed()
cannot be called, in general,
to determine if a database connection is valid or invalid. A typical client can
determine that a connection is invalid by catching the exception that is thrown when an
operation is attempted.
Statement.setCursorName()
method provides a way for an application to specify
a cursor name for the cursor associated with the next result set produced by a statement.
A result set's cursor name can be retrieved by calling
ResultSet.getCursorName().
If Statement.setCursorName()
is called prior to
creating a result set, then ResultSet.getCursorName()
should always return the value
specified in Statement.setCursorName().
We note that calling Statement.setCursorName()
prior to creating a result set does
not mean that the result set is updatable, in other words, positioned update or delete may
not be allowed on a result set even if Statement.setCursorName()
was called. By default
, a result set is read-only.
The only use for a cursor name is to embed it in a SQL statement of the form
UPDATE ... WHERE CURRENT OF <cursor>
The cursor name provides a way to do a positioned update or delete. To enable positioned update and delete on a result set, a select query of the form
SELECT FOR UPDATE
... FROM ... WHERE ...
should be used to create the result set. If Statement.setCursorName()
is not called to
specify a cursor name, then the JDBC driver or underlying DBMS must generate a cursor
name when a SELECT FOR UPDATE
statement is executed, if positioned update/delete
is supported. ResultSet.getCursorName()
should return null
if the result set is
read-only and Statement.setCursorName()
was not called to specify a cursor name.
ResultSet
object that is created by a metadata operation is only required to be forward-only.
Scrollability is not required for result sets produced by DatabaseMetaData
operations.