|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--javax.sql.CachedRowSet
A CachedRowSet is a disconnected, serializable, scrollable container for tabular data. A primary purpose of the CachedRowSet class is to provide a representation of a JDBC ResultSet that can be passed between different components of a remote application. For example, a CachedResultSet can be used to send the result of a query executed by an Enterprise JavaBeans component running in a server environment over a network to a client running in a web browser. A second use for CachedRowSets is to provide scrolling and updating for ResultSets that don't provide these capabilities themselves. A CachedRowSet can be used to augment the capabilities of a JDBC driver that doesn't have full support for scrolling and updating. Finally, a CachedRowSet can be used to provide Java applications with access to tabular data in an environment such as a thin client or PDA, where it would be inappropriate to use a JDBC driver due to resource limitations or security considerations. The CachedRowSet class provides a means to "get rows in" and "get changed rows out" without the need to implement the full JDBC API.
A CachedRowSet object can contain data retrieved via a JDBC driver or data from some other source, such as a spreadsheet. Both a CachedRowSet object and its metadata can be created from scratch. A component that acts as a factory for rowsets can use this capability to create a rowset containing data from non-JDBC data sources. We expect that rowset objects will contain data that was fetched from an SQL database using JDBC most of the time.
The term 'disconnected' implies that a CachedRowSet only makes use of a JDBC connection briefly while data is being read from the database and used to populate it with rows, and again while updated rows are being propagated back to the underlying database. During the remainder of its lifetime, a CachedRowSet object isn't associated with an underlying database connection. A CachedRowSet object can simply be thought of as a disconnected set of rows that are being cached outside of a data source. Since all data is cached in memory, CachedRowSets are not appropriate for extremely large data sets.
The contents of a CachedRowSet may be updated and the updates can be propagated to an underlying data source. CachedRowSets support an optimistic concurrency control mechanism---no locks are maintained in the underlying database during disconnected use of the rowset. The CachedRowSet class provides an extensible reader/writer facility that allows for customization of data retrieval and updating. Both the original value and current value of the CachedRowSet are maintained for use by the optimistic CC routines.
| Constructor Summary | |
CachedRowSet()
Create a CachedRowSet object. |
|
| Method Summary | |
void |
acceptChanges()
Propagate all row update, insert, and delete changes to a data source. |
void |
acceptChanges(java.sql.Connection con)
Like acceptChanges() above, but takes a Connection argument. |
void |
cancelRowDelete()
Cancels deletion of the current row. |
void |
cancelRowInsert()
Cancels insertion of the current row. |
java.lang.Object |
clone()
Returns an identical rowset object backed by a deep copy of this rowset's data. |
RowSet |
createCopy()
Same as clone() above(). |
RowSet |
createShared()
Returns a new rowset object backed by the same data. |
void |
execute(java.sql.Connection connection)
Populates the rowset with data. |
RowSetReader |
getReader()
Get the rowset's reader. |
boolean |
getShowDeleted()
This property determines whether or not rows marked for deletion appear in the set of current rows. |
RowSetWriter |
getWriter()
Get the rowset's writer. |
void |
populate(java.sql.ResultSet data)
Populate the CachedRowSet object with data from a ResultSet. |
void |
release()
Releases the current contents of the rowset. |
void |
restoreOriginal()
Restores the rowset to its original state, i.e. |
void |
setReader(RowSetReader reader)
Set the rowset's reader. |
void |
setShowDeleted(boolean value)
Set the show deleted property. |
void |
setWriter(RowSetWriter writer)
Set the rowset's writer. |
java.util.Collection |
toCollection()
Convert the rowset to a collection of tables. |
java.util.Collection |
toCollection(int column)
Return a column of the rowset as a collection. |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Constructor Detail |
public CachedRowSet()
throws java.sql.SQLException
| Method Detail |
public boolean getShowDeleted()
throws java.sql.SQLException
public void setShowDeleted(boolean value)
throws java.sql.SQLException
value - true if deleted rows should be shown, false otherwise
public void populate(java.sql.ResultSet data)
throws java.sql.SQLException
data - the data to be readpublic void execute(java.sql.Connection connection)
public void acceptChanges()
throws java.sql.SQLException
public void acceptChanges(java.sql.Connection con)
throws java.sql.SQLException
con - a database connection
public void restoreOriginal()
throws java.sql.SQLException
public void release()
throws java.sql.SQLException
public void cancelRowDelete()
throws java.sql.SQLException
public void cancelRowInsert()
throws java.sql.SQLException
public RowSet createShared()
throws java.sql.SQLException
public java.lang.Object clone()
public RowSet createCopy()
throws java.sql.SQLException
public java.util.Collection toCollection()
throws java.sql.SQLException
public java.util.Collection toCollection(int column)
throws java.sql.SQLException
public RowSetReader getReader()
throws java.sql.SQLException
public void setReader(RowSetReader reader)
throws java.sql.SQLException
reader - a new RowSetReader (what if null?)
public RowSetWriter getWriter()
throws java.sql.SQLException
public void setWriter(RowSetWriter writer)
throws java.sql.SQLException
writer - a new RowSetWriter (what if null?)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||