Interface JdbcRowSet
- All Superinterfaces:
AutoCloseable
,Joinable
,ResultSet
,RowSet
,Wrapper
JdbcRowSet
must implement.
1.0 Overview
A wrapper around aResultSet
object that makes it possible
to use the result set as a JavaBeans
component. Thus, a JdbcRowSet
object can be one of the Beans that
a tool makes available for composing an application. Because
a JdbcRowSet
is a connected rowset, that is, it continually
maintains its connection to a database using a JDBC technology-enabled
driver, it also effectively makes the driver a JavaBeans component.
Because it is always connected to its database, an instance of
JdbcRowSet
can simply take calls invoked on it and in turn call them on its
ResultSet
object. As a consequence, a result set can, for
example, be a component in a Swing application.
Another advantage of a JdbcRowSet
object is that it can be
used to make a ResultSet
object scrollable and updatable. All
RowSet
objects are by default scrollable and updatable. If
the driver and database being used do not support scrolling and/or updating
of result sets, an application can populate a JdbcRowSet
object
with the data of a ResultSet
object and then operate on the
JdbcRowSet
object as if it were the ResultSet
object.
2.0 Creating a JdbcRowSet
Object
The reference implementation of the JdbcRowSet
interface,
JdbcRowSetImpl
, provides an implementation of
the default constructor. A new instance is initialized with
default values, which can be set with new values as needed. A
new instance is not really functional until its execute
method is called. In general, this method does the following:
- establishes a connection with a database
- creates a
PreparedStatement
object and sets any of its placeholder parameters - executes the statement to create a
ResultSet
object
execute
method is successful, it will set the
appropriate private JdbcRowSet
fields with the following:
- a
Connection
object -- the connection between the rowset and the database - a
PreparedStatement
object -- the query that produces the result set - a
ResultSet
object -- the result set that the rowset's command produced and that is being made, in effect, a JavaBeans component
execute
method has not executed successfully, no methods other than
execute
and close
may be called on the
rowset. All other public methods will throw an exception.
Before calling the execute
method, however, the command
and properties needed for establishing a connection must be set.
The following code fragment creates a JdbcRowSetImpl
object,
sets the command and connection properties, sets the placeholder parameter,
and then invokes the method execute
.
JdbcRowSetImpl jrs = new JdbcRowSetImpl(); jrs.setCommand("SELECT * FROM TITLES WHERE TYPE = ?"); jrs.setURL("jdbc:myDriver:myAttribute"); jrs.setUsername("cervantes"); jrs.setPassword("sancho"); jrs.setString(1, "BIOGRAPHY"); jrs.execute();The variable
jrs
now represents an instance of
JdbcRowSetImpl
that is a thin wrapper around the
ResultSet
object containing all the rows in the
table TITLES
where the type of book is biography.
At this point, operations called on jrs
will
affect the rows in the result set, which is effectively a JavaBeans
component.
The implementation of the RowSet
method execute
in the
JdbcRowSet
reference implementation differs from that in the
CachedRowSet
reference implementation to account for the different
requirements of connected and disconnected RowSet
objects.
- Since:
- 1.5
-
Field Summary
Fields declared in interface java.sql.ResultSet
CLOSE_CURSORS_AT_COMMIT, CONCUR_READ_ONLY, CONCUR_UPDATABLE, FETCH_FORWARD, FETCH_REVERSE, FETCH_UNKNOWN, HOLD_CURSORS_OVER_COMMIT, TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, TYPE_SCROLL_SENSITIVE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
commit()
EachJdbcRowSet
contains aConnection
object from theResultSet
or JDBC properties passed to it's constructors.boolean
EachJdbcRowSet
contains aConnection
object from the originalResultSet
or JDBC properties passed to it.Retrieves the first warning reported by calls on thisJdbcRowSet
object.boolean
Retrieves aboolean
indicating whether rows marked for deletion appear in the set of current rows.void
rollback()
EachJdbcRowSet
contains aConnection
object from the originalResultSet
or JDBC properties passed to it.void
EachJdbcRowSet
contains aConnection
object from the originalResultSet
or JDBC properties passed to it.void
setAutoCommit
(boolean autoCommit) EachJdbcRowSet
contains aConnection
object from the originalResultSet
or JDBC properties passed to it.void
setShowDeleted
(boolean b) Sets the propertyshowDeleted
to the givenboolean
value.Methods declared in interface javax.sql.rowset.Joinable
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn
Methods declared in interface java.sql.ResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getMetaData, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt,