WebRowSet (Java 2 Platform SE 5.0) (original) (raw)
javax.sql.rowset
Interface WebRowSet
All Superinterfaces:
CachedRowSet, Joinable, ResultSet, RowSet
All Known Subinterfaces:
public interface WebRowSet
extends CachedRowSet
The standard interface that all implementations of a WebRowSet
must implement.
1.0 Overview
The WebRowSetImpl
provides the standard reference implementation, which may be extended if required.
The standard WebRowSet XML Schema definition is available at the following URI:
http://java.sun.com/xml/ns/jdbc/webrowset.xsd
It describes the standard XML document format required when describing aRowSet
object in XML and must be used be all standard implementations of the WebRowSet
interface to ensure interoperability. In addition, the WebRowSet
schema uses specific SQL/XML Schema annotations, thus ensuring greater cross platform inter-operability. This is an effort currently under way at the ISO organization. The SQL/XML definition is available at the following URI:
http://standards.iso.org/iso/9075/2002/12/sqlxml
The schema definition describes the internal data of a RowSet
object in three distinct areas:
- properties
These properties describe the standard synchronization provider properties in addition to the more general
RowSet
properties. - metadata
This describes the metadata associated with the tabular structure governed by a
WebRowSet
object. The metadata described is closely aligned with the metadata accessible in the underlyingjava.sql.ResultSet
interface. - data
This describes the original data (the state of data since the last population or last synchronization of the
WebRowSet
object) and the current data. By keeping track of the delta between the original data and the current data, aWebRowSet
maintains the ability to synchronize changes in its data back to the originating data source.
2.0 WebRowSet States
The following sections demonstrates how a WebRowSet
implementation should use the XML Schema to describe update, insert, and delete operations and to describe the state of a WebRowSet
object in XML.
2.1 State 1 - Outputting a WebRowSet
Object to XML
In this example, a WebRowSet
object is created and populated with a simple 2 column, 5 row table from a data source. Having the 5 rows in a WebRowSet
object makes it possible to describe them in XML. The metadata describing the various standard JavaBeans properties as defined in the RowSet interface plus the standard properties defined in the CachedRowSet
TM interface provide key details that describe WebRowSet properties. Outputting the WebRowSet object to XML using the standard writeXml
methods describes the internal properties as follows:
The meta-data describing the make up of the WebRowSet is described in XML as detailed below. Note both columns are described between the column-definition
tags.
Having detailed how the properties and metadata are described, the following details how the contents of a WebRowSet
object is described in XML. Note, that this describes a WebRowSet
object that has not undergone any modifications since its instantiation. A currentRow
tag is mapped to each row of the table structure that theWebRowSet
object provides. A columnValue
tag may contain either the stringData
or binaryData
tag, according to the SQL type that the XML value is mapping back to. The binaryData
tag contains data in the Base64 encoding and is typically used for BLOB
and CLOB
type data.
2.2 State 2 - Deleting a Row
Deleting a row in a WebRowSet
object involves simply moving to the row to be deleted and then calling the method deleteRow
, as in any otherRowSet
object. The following two lines of code, in which wrs is a WebRowSet
object, delete the third row.
wrs.absolute(3);
wrs.deleteRow();
The XML description shows the third row is marked as a deleteRow
, which eliminates the third row in the WebRowSet
object.
2.3 State 3 - Inserting a Row
A <codewebrowset< code=""> object can insert a new row by moving to the insert row, calling the appropriate updater methods for each column in the row, and then calling the method insertRow
.
wrs.moveToInsertRow(); wrs.updateString(1, "fifththrow"); wrs.updateString(2, "5"); wrs.insertRow();
The following code fragment changes the second column value in the row just inserted. Note that this code applies when new rows are inserted right after the current row, which is why the method next
moves the cursor to the correct row. Calling the method acceptChanges
writes the change to the data source.
wrs.moveToCurrentRow(); wrs.next(); wrs.updateString(2, "V"); wrs.acceptChanges(); :
Describing this in XML demonstrates where the Java code inserts a new row and then performs an update on the newly inserted row on an individual field.
firstrow 1 secondrow 2 newthirdrow III fifthrow 5 V fourthrow 42.4 State 4 - Modifying a Row
Modifying a row produces specific XML that records both the new value and the value that was replaced. The value that was replaced becomes the original value, and the new value becomes the current value. The following code moves the cursor to a specific row, performs some modifications, and updates the row when complete.
wrs.absolute(5); wrs.updateString(1, "new4thRow"); wrs.updateString(2, "IV"); wrs.updateRow();
In XML, this is described by the modifyRow
tag. Both the original and new values are contained within the tag for original row tracking purposes.
See Also:
JdbcRowSet, CachedRowSet, FilteredRowSet, JoinRowSet
Field Summary | |
---|---|
static String | PUBLIC_XML_SCHEMA The public identifier for the XML Schema definition that defines the XML tags and their valid values for a WebRowSet implementation. |
static String | SCHEMA_SYSTEM_ID The URL for the XML Schema definition file that defines the XML tags and their valid values for a WebRowSet implementation. |
Fields inherited from interface javax.sql.rowset.CachedRowSet |
---|
COMMIT_ON_ACCEPT_CHANGES |
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 | readXml(InputStream iStream) Reads a stream based XML input to populate this WebRowSet object. |
void | readXml(Reader reader) Reads a WebRowSet object in its XML format from the given Reader object. |
void | writeXml(OutputStream oStream) Writes the data, properties, and metadata for this WebRowSet object to the given OutputStream object in XML format. |
void | [writeXml](../../../javax/sql/rowset/WebRowSet.html#writeXml%28java.sql.ResultSet, java.io.OutputStream%29)(ResultSet rs,OutputStream oStream) Populates this WebRowSet object with the contents of the given ResultSet object and writes its data, properties, and metadata to the given OutputStream object in XML format. |
void | [writeXml](../../../javax/sql/rowset/WebRowSet.html#writeXml%28java.sql.ResultSet, java.io.Writer%29)(ResultSet rs,Writer writer) Populates this WebRowSet object with the contents of the given ResultSet object and writes its data, properties, and metadata to the given Writer object in XML format. |
void | writeXml(Writer writer) Writes the data, properties, and metadata for this WebRowSet object to the given Writer object in XML format. |
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](../../../javax/sql/rowset/CachedRowSet.html#populate%28java.sql.ResultSet, int%29), previousPage, release, restoreOriginal, rollback, rollback, [rowSetPopulated](../../../javax/sql/rowset/CachedRowSet.html#rowSetPopulated%28javax.sql.RowSetEvent, int%29), setKeyColumns, setMetaData, setOriginalRow, setPageSize, setShowDeleted, setSyncProvider, setTableName, size, toCollection, toCollection, toCollection, undoDelete, undoInsert, undoUpdate |
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 |
Field Detail |
---|
PUBLIC_XML_SCHEMA
static final String PUBLIC_XML_SCHEMA
The public identifier for the XML Schema definition that defines the XML tags and their valid values for a WebRowSet
implementation.
See Also:
SCHEMA_SYSTEM_ID
static final String SCHEMA_SYSTEM_ID
The URL for the XML Schema definition file that defines the XML tags and their valid values for a WebRowSet
implementation.
See Also:
Method Detail |
---|
readXml
void readXml(Reader reader) throws SQLException
Reads a WebRowSet
object in its XML format from the given Reader
object.
Parameters:
reader
- the java.io.Reader
stream from which thisWebRowSet
object will be populated
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if a database access error occurs
readXml
void readXml(InputStream iStream) throws SQLException, IOException
Reads a stream based XML input to populate this WebRowSet
object.
Parameters:
iStream
- the java.io.InputStream
from which thisWebRowSet
object will be populated
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if a data source access error occurs
[IOException](../../../java/io/IOException.html "class in java.io")
- if an IO exception occurs
writeXml
void writeXml(ResultSet rs, Writer writer) throws SQLException
Populates this WebRowSet
object with the contents of the given ResultSet
object and writes its data, properties, and metadata to the given Writer
object in XML format.
NOTE: The WebRowSet
cursor may be moved to write out the contents to the XML data source. If implemented in this way, the cursor must be returned to its position just prior to the writeXml()
call.
Parameters:
rs
- the ResultSet
object with which to populate thisWebRowSet
object
writer
- the java.io.Writer
object to write to.
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if an error occurs writing out the rowset contents in XML format
writeXml
void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException
Populates this WebRowSet
object with the contents of the given ResultSet
object and writes its data, properties, and metadata to the given OutputStream
object in XML format.
NOTE: The WebRowSet
cursor may be moved to write out the contents to the XML data source. If implemented in this way, the cursor must be returned to its position just prior to the writeXml()
call.
Parameters:
rs
- the ResultSet
object with which to populate thisWebRowSet
object
oStream
- the java.io.OutputStream
to write to
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if a data source access error occurs
[IOException](../../../java/io/IOException.html "class in java.io")
- if a IO exception occurs
writeXml
void writeXml(Writer writer) throws SQLException
Writes the data, properties, and metadata for this WebRowSet
object to the given Writer
object in XML format.
Parameters:
writer
- the java.io.Writer
stream to write to
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if an error occurs writing out the rowset contents to XML
writeXml
void writeXml(OutputStream oStream) throws SQLException, IOException
Writes the data, properties, and metadata for this WebRowSet
object to the given OutputStream
object in XML format.
Parameters:
oStream
- the java.io.OutputStream
stream to write to
Throws:
[SQLException](../../../java/sql/SQLException.html "class in java.sql")
- if a data source access error occurs
[IOException](../../../java/io/IOException.html "class in java.io")
- if a IO exception occurs
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.
</codewebrowset<>