JdbcRowSet must implement.
ResultSet 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.
JdbcRowSet ObjectJdbcRowSet 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:
PreparedStatement object and sets any of its
placeholder parameters
ResultSet object
execute method is successful, it will set the
appropriate private JdbcRowSet fields with the following:
Connection object -- the connection between the rowset
and the database
PreparedStatement object -- the query that produces
the result set
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.
| Modifier and Type | Method and Description |
|---|---|
| public void | commit()
Each |
| public boolean | Returns: true if auto-commit is enabled; false otherwiseEach |
| public RowSetWarning | Returns: the firstRowSetWarning
object reported on this JdbcRowSet object
or null if there are noneRetrieves the first warning reported by calls on this |
| public boolean | Returns: true if deleted rows are visible;
false otherwiseRetrieves a |
| public void | rollback()
Each |
| public void | |
| public void | setAutoCommit(boolean
true to enable auto-commit; false to
disable auto-commitEach |
| public void | setShowDeleted(boolean
true if deleted rows should be shown;
false otherwiseSets the property |
| commit | back to summary |
|---|---|
| public void commit() throws SQLException Each Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.
| |
| getAutoCommit | back to summary |
|---|---|
| public boolean getAutoCommit() throws SQLException Each Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the method commit or the method rollback. By default, new connections are in auto-commit mode.
| |
| getRowSetWarnings | back to summary |
|---|---|
| public RowSetWarning getRowSetWarnings() throws SQLException Retrieves the first warning reported by calls on this
Because it is always connected to its data source, a
| |
| getShowDeleted | back to summary |
|---|---|
| public boolean getShowDeleted() throws SQLException Retrieves a Standard rowset implementations may choose to restrict this behavior for security considerations or for certain deployment scenarios. The visibility of deleted rows is implementation-defined and does not represent standard behavior. Note Allowing deleted rows to remain visible complicates the behavior
of some standard JDBC
| |
| rollback | back to summary |
|---|---|
| public void rollback() throws SQLException Each
| |
| rollback | back to summary |
|---|---|
| public void rollback(Savepoint s) throws SQLException Each
| |
| setAutoCommit | back to summary |
|---|---|
| public void setAutoCommit(boolean autoCommit) throws SQLException Each
Sets the current auto-commit mode for this
| |
| setShowDeleted | back to summary |
|---|---|
| public void setShowDeleted(boolean b) throws SQLException Sets the property Standard rowset implementations may choose to restrict this behavior for security considerations or for certain deployment scenarios. This is left as implementation-defined and does not represent standard behavior.
| |