JdbcRowSet (Java 2 Platform SE 5.0) (original) (raw)


javax.sql.rowset

Interface JdbcRowSet

All Superinterfaces:

Joinable, ResultSet, RowSet


public interface JdbcRowSet

extends RowSet, Joinable

The standard interface that all standard implementations of JdbcRowSet must implement.

1.0 Overview

A wrapper around a ResultSet object that makes it possible to use the result set as a JavaBeansTM 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 itsResultSet 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. AllRowSet 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 theJdbcRowSet 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:

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 ofJdbcRowSetImpl that is a thin wrapper around theResultSet 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 CachedRowSetTM reference implementation to account for the different requirements of connected and disconnected RowSet objects.


Field Summary
Fields inherited from 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
void commit() Each JdbcRowSet contains a Connection object from the ResultSet or JDBC properties passed to it's constructors.
boolean getAutoCommit() Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it.
RowSetWarning getRowSetWarnings() Retrieves the first warning reported by calls on this JdbcRowSet object.
boolean getShowDeleted() Retrieves a boolean indicating whether rows marked for deletion appear in the set of current rows.
void rollback() Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it.
void rollback(Savepoint s) Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it.
void setAutoCommit(boolean autoCommit) Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it.
void setShowDeleted(boolean b) Sets the property showDeleted to the givenboolean value.
Methods inherited from interface javax.sql.RowSet
addRowSetListener, clearParameters, execute, getCommand, getDataSourceName, getEscapeProcessing, getMaxFieldSize, getMaxRows, getPassword, getQueryTimeout, getTransactionIsolation, getTypeMap, getUrl, getUsername, isReadOnly, removeRowSetListener, [setArray](../../../javax/sql/RowSet.html#setArray%28int, java.sql.Array%29), [setAsciiStream](../../../javax/sql/RowSet.html#setAsciiStream%28int, java.io.InputStream, int%29), [setBigDecimal](../../../javax/sql/RowSet.html#setBigDecimal%28int, java.math.BigDecimal%29), [setBinaryStream](../../../javax/sql/RowSet.html#setBinaryStream%28int, java.io.InputStream, int%29), [setBlob](../../../javax/sql/RowSet.html#setBlob%28int, java.sql.Blob%29), [setBoolean](../../../javax/sql/RowSet.html#setBoolean%28int, boolean%29), [setByte](../../../javax/sql/RowSet.html#setByte%28int, byte%29), [setBytes](../../../javax/sql/RowSet.html#setBytes%28int, byte[]%29), [setCharacterStream](../../../javax/sql/RowSet.html#setCharacterStream%28int, java.io.Reader, int%29), [setClob](../../../javax/sql/RowSet.html#setClob%28int, java.sql.Clob%29), setCommand, setConcurrency, setDataSourceName, [setDate](../../../javax/sql/RowSet.html#setDate%28int, java.sql.Date%29), [setDate](../../../javax/sql/RowSet.html#setDate%28int, java.sql.Date, java.util.Calendar%29), [setDouble](../../../javax/sql/RowSet.html#setDouble%28int, double%29), setEscapeProcessing, [setFloat](../../../javax/sql/RowSet.html#setFloat%28int, float%29), [setInt](../../../javax/sql/RowSet.html#setInt%28int, int%29), [setLong](../../../javax/sql/RowSet.html#setLong%28int, long%29), setMaxFieldSize, setMaxRows, [setNull](../../../javax/sql/RowSet.html#setNull%28int, int%29), [setNull](../../../javax/sql/RowSet.html#setNull%28int, int, java.lang.String%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object, int%29), [setObject](../../../javax/sql/RowSet.html#setObject%28int, java.lang.Object, int, int%29), setPassword, setQueryTimeout, setReadOnly, [setRef](../../../javax/sql/RowSet.html#setRef%28int, java.sql.Ref%29), [setShort](../../../javax/sql/RowSet.html#setShort%28int, short%29), [setString](../../../javax/sql/RowSet.html#setString%28int, java.lang.String%29), [setTime](../../../javax/sql/RowSet.html#setTime%28int, java.sql.Time%29), [setTime](../../../javax/sql/RowSet.html#setTime%28int, java.sql.Time, java.util.Calendar%29), [setTimestamp](../../../javax/sql/RowSet.html#setTimestamp%28int, java.sql.Timestamp%29), [setTimestamp](../../../javax/sql/RowSet.html#setTimestamp%28int, java.sql.Timestamp, java.util.Calendar%29), setTransactionIsolation, setType, setTypeMap, setUrl, setUsername
Methods inherited from interface java.sql.ResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, [getBigDecimal](../../../java/sql/ResultSet.html#getBigDecimal%28int, int%29), getBigDecimal, [getBigDecimal](../../../java/sql/ResultSet.html#getBigDecimal%28java.lang.String, int%29), getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, [getDate](../../../java/sql/ResultSet.html#getDate%28int, java.util.Calendar%29), getDate, [getDate](../../../java/sql/ResultSet.html#getDate%28java.lang.String, java.util.Calendar%29), getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getInt, getInt, getLong, getLong, getMetaData, getObject, [getObject](../../../java/sql/ResultSet.html#getObject%28int, java.util.Map%29), getObject, [getObject](../../../java/sql/ResultSet.html#getObject%28java.lang.String, java.util.Map%29), getRef, getRef, getRow, getShort, getShort, getStatement, getString, getString, getTime, [getTime](../../../java/sql/ResultSet.html#getTime%28int, java.util.Calendar%29), getTime, [getTime](../../../java/sql/ResultSet.html#getTime%28java.lang.String, java.util.Calendar%29), getTimestamp, [getTimestamp](../../../java/sql/ResultSet.html#getTimestamp%28int, java.util.Calendar%29), getTimestamp, [getTimestamp](../../../java/sql/ResultSet.html#getTimestamp%28java.lang.String, java.util.Calendar%29), getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, [updateArray](../../../java/sql/ResultSet.html#updateArray%28int, java.sql.Array%29), [updateArray](../../../java/sql/ResultSet.html#updateArray%28java.lang.String, java.sql.Array%29), [updateAsciiStream](../../../java/sql/ResultSet.html#updateAsciiStream%28int, java.io.InputStream, int%29), [updateAsciiStream](../../../java/sql/ResultSet.html#updateAsciiStream%28java.lang.String, java.io.InputStream, int%29), [updateBigDecimal](../../../java/sql/ResultSet.html#updateBigDecimal%28int, java.math.BigDecimal%29), [updateBigDecimal](../../../java/sql/ResultSet.html#updateBigDecimal%28java.lang.String, java.math.BigDecimal%29), [updateBinaryStream](../../../java/sql/ResultSet.html#updateBinaryStream%28int, java.io.InputStream, int%29), [updateBinaryStream](../../../java/sql/ResultSet.html#updateBinaryStream%28java.lang.String, java.io.InputStream, int%29), [updateBlob](../../../java/sql/ResultSet.html#updateBlob%28int, java.sql.Blob%29), [updateBlob](../../../java/sql/ResultSet.html#updateBlob%28java.lang.String, java.sql.Blob%29), [updateBoolean](../../../java/sql/ResultSet.html#updateBoolean%28int, boolean%29), [updateBoolean](../../../java/sql/ResultSet.html#updateBoolean%28java.lang.String, boolean%29), [updateByte](../../../java/sql/ResultSet.html#updateByte%28int, byte%29), [updateByte](../../../java/sql/ResultSet.html#updateByte%28java.lang.String, byte%29), [updateBytes](../../../java/sql/ResultSet.html#updateBytes%28int, byte[]%29), [updateBytes](../../../java/sql/ResultSet.html#updateBytes%28java.lang.String, byte[]%29), [updateCharacterStream](../../../java/sql/ResultSet.html#updateCharacterStream%28int, java.io.Reader, int%29), [updateCharacterStream](../../../java/sql/ResultSet.html#updateCharacterStream%28java.lang.String, java.io.Reader, int%29), [updateClob](../../../java/sql/ResultSet.html#updateClob%28int, java.sql.Clob%29), [updateClob](../../../java/sql/ResultSet.html#updateClob%28java.lang.String, java.sql.Clob%29), [updateDate](../../../java/sql/ResultSet.html#updateDate%28int, java.sql.Date%29), [updateDate](../../../java/sql/ResultSet.html#updateDate%28java.lang.String, java.sql.Date%29), [updateDouble](../../../java/sql/ResultSet.html#updateDouble%28int, double%29), [updateDouble](../../../java/sql/ResultSet.html#updateDouble%28java.lang.String, double%29), [updateFloat](../../../java/sql/ResultSet.html#updateFloat%28int, float%29), [updateFloat](../../../java/sql/ResultSet.html#updateFloat%28java.lang.String, float%29), [updateInt](../../../java/sql/ResultSet.html#updateInt%28int, int%29), [updateInt](../../../java/sql/ResultSet.html#updateInt%28java.lang.String, int%29), [updateLong](../../../java/sql/ResultSet.html#updateLong%28int, long%29), [updateLong](../../../java/sql/ResultSet.html#updateLong%28java.lang.String, long%29), updateNull, updateNull, [updateObject](../../../java/sql/ResultSet.html#updateObject%28int, java.lang.Object%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28int, java.lang.Object, int%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28java.lang.String, java.lang.Object%29), [updateObject](../../../java/sql/ResultSet.html#updateObject%28java.lang.String, java.lang.Object, int%29), [updateRef](../../../java/sql/ResultSet.html#updateRef%28int, java.sql.Ref%29), [updateRef](../../../java/sql/ResultSet.html#updateRef%28java.lang.String, java.sql.Ref%29), updateRow, [updateShort](../../../java/sql/ResultSet.html#updateShort%28int, short%29), [updateShort](../../../java/sql/ResultSet.html#updateShort%28java.lang.String, short%29), [updateString](../../../java/sql/ResultSet.html#updateString%28int, java.lang.String%29), [updateString](../../../java/sql/ResultSet.html#updateString%28java.lang.String, java.lang.String%29), [updateTime](../../../java/sql/ResultSet.html#updateTime%28int, java.sql.Time%29), [updateTime](../../../java/sql/ResultSet.html#updateTime%28java.lang.String, java.sql.Time%29), [updateTimestamp](../../../java/sql/ResultSet.html#updateTimestamp%28int, java.sql.Timestamp%29), [updateTimestamp](../../../java/sql/ResultSet.html#updateTimestamp%28java.lang.String, java.sql.Timestamp%29), wasNull
Methods inherited from interface javax.sql.rowset.Joinable
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn
Method Detail

getShowDeleted

boolean getShowDeleted() throws SQLException

Retrieves a boolean indicating whether rows marked for deletion appear in the set of current rows. If true is returned, deleted rows are visible with the current rows. If false is returned, rows are not visible with the set of current rows. The default value is false.

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 RowSet implementations methods. However, most rowset users can simply ignore this extra detail because only very specialized applications will likely want to take advantage of this feature.

Returns:

true if deleted rows are visible;false otherwise

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a rowset implementation is unable to to determine whether rows marked for deletion remain visible

See Also:

setShowDeleted(boolean)


setShowDeleted

void setShowDeleted(boolean b) throws SQLException

Sets the property showDeleted to the givenboolean value. This property determines whether rows marked for deletion continue to appear in the set of current rows. If the value is set to true, deleted rows are immediately visible with the set of current rows. If the value is set to false, the deleted rows are set as invisible with the current set of rows.

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.

Parameters:

b - true if deleted rows should be shown;false otherwise

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a rowset implementation is unable to to reset whether deleted rows should be visible

See Also:

getShowDeleted()


getRowSetWarnings

RowSetWarning getRowSetWarnings() throws SQLException

Retrieves the first warning reported by calls on this JdbcRowSet object. If a second warning was reported on this JdbcRowSet object, it will be chained to the first warning and can be retrieved by calling the method RowSetWarning.getNextWarning on the first warning. Subsequent warnings on this JdbcRowSet object will be chained to the RowSetWarning objects returned by the method RowSetWarning.getNextWarning. The warning chain is automatically cleared each time a new row is read. This method may not be called on a RowSet object that has been closed; doing so will cause an SQLException to be thrown.

Because it is always connected to its data source, a JdbcRowSet object can rely on the presence of active Statement, Connection, and ResultSet instances. This means that applications can obtain additional SQLWarning notifications by calling the getNextWarning methods that they provide. Disconnected Rowset objects, such as a CachedRowSet object, do not have access to these getNextWarning methods.

Returns:

the first RowSetWarning object reported on this JdbcRowSet object or null if there are none

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if this method is called on a closed JdbcRowSet object

See Also:

RowSetWarning


commit

void commit() throws SQLException

Each JdbcRowSet contains a Connection object from the ResultSet or JDBC properties passed to it's constructors. This method wraps the Connection commit method to allow flexible auto commit or non auto commit transactional control support.

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.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a database access error occurs or this Connection object within this JdbcRowSet is in auto-commit mode

See Also:

Connection.setAutoCommit(boolean)


getAutoCommit

boolean getAutoCommit() throws SQLException

Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it. This method wraps the Connection's getAutoCommit method to allow an application to determine the JdbcRowSet transaction behavior.

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.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a database access error occurs

See Also:

Connection.getAutoCommit()


setAutoCommit

void setAutoCommit(boolean autoCommit) throws SQLException

Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it. This method wraps the Connection's getAutoCommit method to allow an application to set the JdbcRowSet transaction behavior.

Sets the current auto-commit mode for this Connection object.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a database access error occurs

See Also:

Connection.setAutoCommit(boolean)


rollback

void rollback() throws SQLException

Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it. Undoes all changes made in the current transaction and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a database access error occurs or this Connection object within this JdbcRowSet is in auto-commit mode.

See Also:

rollback(Savepoint)


rollback

void rollback(Savepoint s) throws SQLException

Each JdbcRowSet contains a Connection object from the original ResultSet or JDBC properties passed to it. Undoes all changes made in the current transaction to the last set savepoint and releases any database locks currently held by this Connection object. This method should be used only when auto-commit mode has been disabled.

Throws:

[SQLException](../../../java/sql/SQLException.html "class in java.sql") - if a database access error occurs or this Connection object within this JdbcRowSet is in auto-commit mode.

See Also:

rollback()



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.