|
BEA Systems, Inc. | |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
WLCachedRowSet
is an extension to the
javax.sql.RowSet
interface.
WLCachedRowSet
is a disconnected RowSet. Data is
read into the RowSet from a JDBC query, an existing
java.sql.ResultSet
, or an XML document.
The RowSet then has the data in memory and does not maintain any open
connections or transactions in the database.
All reads, writes, deletes, and inserts occur in memory. When the
acceptChanges
method is called, the
WLCachedRowSet
writes any inserts, updates, or deletes
to the database.
Since the WLCachedRowSet
does not hold open any
transactions between reading and updating the data, it uses
optimistic concurrency control to verify the state of the
underlying database row has not changed.
The WLCachedRowSet
interface extends
java.io.Serializable
so a WLCachedRowSet
may be serialized and sent across a network connection to a client.
The WLCachedRowSet
may be written as an XML instance
document. This XML document captures the row(s) currently cached
in the WLCachedRowSet
A WLCachedRowSet
is created from the RowSetFactory class.
RowSetFactory factory = RowSetFactory.newInstance(); WLCachedRowSet rowSet = factory.newCachedRowSet();
A detailed discussion of the WLCachedRowSet
's optimistic
concurrency control options can be found in the
WLRowSetMetaData
javadocs.
WLRowSetMetaData
Field Summary | |
static int |
ALL_ROWS
XML Document includes all rows with both their changed and original values |
static int |
CHANGED_ALL
XML Document includes the current and original values for all changed rows. |
static int |
CHANGED_CURRENT
XML Document includes only changed rows with their current values. |
static int |
CHANGED_ORIGINAL
XML Document includes only changed rows with their original values. |
static int |
CURRENT_ALL
XML Document includes the current values for all rows. |
static int |
UNCHANGED_CURRENT
XML Document includes only unchanged rows. |
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 |
Fields inherited from interface javax.sql.rowset.CachedRowSet |
COMMIT_ON_ACCEPT_CHANGES |
Fields inherited from interface javax.sql.rowset.WebRowSet |
PUBLIC_XML_SCHEMA, SCHEMA_SYSTEM_ID |
Method Summary | |
String |
executeAndGuessTableName()
Executes the command, parses it, and sets the table name as the first word following the SQL keyword "from". |
boolean |
executeAndGuessTableNameAndPrimaryKeys()
Executes the command, parses it, sets the table name as the first word following the SQL keyword "from", and then looks up the table in DatabaseMetaData to determine the primary keys. |
Object |
getCacheKey()
|
Map |
getCurrentRow()
Returns a Map representing the current row in the RowSet. |
DataSource |
getDataSource()
Returns the current javax.sql.DataSource for this RowSet. |
Map |
getRow(int index)
Returns a Map representing the row at the specified index. |
Map[] |
getRows()
Returns an array of Maps representing all rows in the rowset |
Map[] |
getRows(int startIndex,
int endIndex)
Returns an array of Maps representing the rows in the rowset from [startIndex...endIndex-1] |
boolean |
isComplete()
Returns whether the populating query read all matching rows, or it hit the maxRows limit. |
void |
loadXML(XMLInputStream xis)
Populates the RowSet from an XML document in the XMLInputStream. |
void |
moveToUpdateRow()
|
void |
populate(ResultSetMetaData md)
Loads a ResultSet from an existing java.sql.ResultSetMetaData . |
void |
setDataSource(DataSource dataSource)
Sets the javax.sql.DataSource used for establishing JDBC Connections. |
void |
setRowSetSynced()
|
void |
setRowSynced()
|
void |
writeXML(XMLOutputStream xos)
Writes the RowSet to the XMLOutputStream as an XML document. |
void |
writeXML(XMLOutputStream xos,
int rowStates)
Writes the RowSet as an XML document. |
Methods inherited from interface javax.sql.rowset.CachedRowSet |
acceptChanges, acceptChanges, columnUpdated, columnUpdated, commit, createCopy, createCopyNoConstraints, createCopySchema, createShared, execute, getKeyColumns, getOriginal, getOriginalRow, getPageSize, getRowSetWarnings, getShowDeleted, getSyncProvider, getTableName, nextPage, populate, populate, previousPage, release, restoreOriginal, rollback, rollback, rowSetPopulated, setKeyColumns, setMetaData, setOriginalRow, setPageSize, setShowDeleted, setSyncProvider, setTableName, size, toCollection, toCollection, toCollection, undoDelete, undoInsert, undoUpdate |
Methods inherited from interface javax.sql.rowset.Joinable |
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn |
Methods inherited from interface javax.sql.rowset.WebRowSet |
readXml, readXml, writeXml, writeXml, writeXml, writeXml |
Methods inherited from interface javax.sql.rowset.FilteredRowSet |
getFilter, setFilter |
Methods inherited from interface weblogic.jdbc.rowset.SortedRowSet |
getSorter, setSorter |
Field Detail |
public static final int ALL_ROWS
public static final int CHANGED_ALL
public static final int CHANGED_CURRENT
public static final int CHANGED_ORIGINAL
public static final int CURRENT_ALL
public static final int UNCHANGED_CURRENT
Method Detail |
public String executeAndGuessTableName() throws SQLException
SQLException
- if a database access error occurs or any of the
properties necessary for making a connection and creating
a statement have not been setpublic boolean executeAndGuessTableNameAndPrimaryKeys() throws SQLException
SQLException
- if a database access error occurs or any of the
properties necessary for making a connection and creating
a statement have not been setpublic Object getCacheKey()
public Map getCurrentRow() throws SQLException
Like java.sql.ResultSet
, a RowSet acts like a cursor
or Iterator with next() and previous() methods. This method
returns a java.util.Map instance representing the row at the
current position.
The returned Map has keys of the column names and values of the
column values. The column values may be read with the get(Object
key)
method and updated with put(Object key, Object value)
method. The user must call updateRow()
after
updating the Map for the RowSet to accept the updated values.
SQLException
- if the current RowSet position is not a
valid rowpublic DataSource getDataSource() throws SQLException
SQLException
- if the DataSource name given to
setDataSourceName cannot be found or is invalid.public Map getRow(int index) throws SQLException
Note: For this method, the starting index number is 0
, which
is different than the starting index for the getRow() method inherited from java.sql.ResultSet.
The starting index for that method is 1
.
index
- row index into the row set. Valid values are [0 ...
row.size() -1]
SQLException
- if the index is not a valid rowpublic Map[] getRows() throws SQLException
SQLException
- if there is an error creating the Map arraypublic Map[] getRows(int startIndex, int endIndex) throws SQLException
startIndex
- the starting rowset indexendIndex
- the end rowset index
SQLException
- if startIndex or endIndex out of bounds or
if startIndex > endIndexpublic boolean isComplete()
When execute
is called, it runs the query specified
by the setCommand
method. The user may optionally
specify a maximum number of rows to return from the query with
the setMaxRows
method.
execute
method.
Returns false if MaxRows has been set, and the query hit the maxRows limit without returning all matching rows
public void loadXML(XMLInputStream xis) throws IOException, SQLException
IOException
SQLException
public void moveToUpdateRow() throws SQLException
SQLException
public void populate(ResultSetMetaData md) throws SQLException
java.sql.ResultSetMetaData
. This method produces an
empty RowSet that can be used to insert new rows.
SQLException
- if there is an error processing the
ResultSetMetaDatapublic void setDataSource(DataSource dataSource) throws SQLException
SQLException
public void setRowSetSynced() throws SQLException
SQLException
public void setRowSynced() throws SQLException
SQLException
public void writeXML(XMLOutputStream xos) throws IOException, SQLException
IOException
- if there is an error writing to the
XMLOutputStream
SQLException
- if there is an error retrieving data from
the RowSetpublic void writeXML(XMLOutputStream xos, int rowStates) throws IOException, SQLException
IOException
SQLException
|
Documentation is available at http://download.oracle.com/docs/cd/E13222_01/wls/docs90 Copyright 2005 BEA Systems Inc. |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |