-
- All Superinterfaces:
-
AutoCloseable,CachedRowSet,Joinable,ResultSet,RowSet,Wrapper
- All Known Subinterfaces:
-
FilteredRowSet,JoinRowSet
public interface WebRowSet extends CachedRowSet
WebRowSet所有实现必须实现的标准接口。1.0概述
WebRowSetImpl提供标准参考实现,如果需要可以扩展。标准的WebRowSet XML Schema定义可从以下URI获得:
它描述了在XML中描述RowSet对象时所需的标准XML文档格式,并且必须用于WebRowSet接口的所有标准实现,以确保互操作性。 此外,WebRowSet模式使用特定的SQL / XML模式注释,从而确保更高的跨平台互操作性。 这是ISO组织目前正在进行的一项工作。 SQL / XML定义可在以下URI中获得: 模式定义在三个不同的区域中描述RowSet对象的内部数据:- properties - 除了更一般的
RowSet属性之外,这些属性还描述了标准同步提供程序属性。 - 元数据 - 这描述了与由
WebRowSet对象控制的表格结构相关联的元数据。 所描述的元数据与底层java.sql.ResultSet界面中可访问的元数据紧密对齐。 - data - 描述原始数据(自上次填充或上次同步
WebRowSet对象以来的数据状态)和当前数据。 通过跟踪原始数据和当前数据之间的差值,WebRowSet保持了将其数据中的更改同步回原始数据源的能力。
2.0 WebRowSet状态
以下部分演示了WebRowSet实现应如何使用XML Schema来描述更新,插入和删除操作,以及如何描述XML中的WebRowSet对象的状态。2.1状态1 - 将
在此示例中,将创建一个WebRowSet对象输出到XMLWebRowSet对象,并使用数据源中的简单2列5行表填充该对象。 在WebRowSet对象中有5行可以用XML描述它们。 描述RowSet接口中定义的各种标准JavaBeans属性的元数据加上CachedRowSetinterface接口中定义的标准属性提供了描述WebRowSet属性的关键详细信息。 使用标准writeXml方法将WebRowSet对象输出到XML描述了内部属性,如下所示:描述WebRowSet组成的元数据在XML中描述,如下所述。 请注意,<properties> <command>select co1, col2 from test_table</command> <concurrency>1</concurrency> <datasource/> <escape-processing>true</escape-processing> <fetch-direction>0</fetch-direction> <fetch-size>0</fetch-size> <isolation-level>1</isolation-level> <key-columns/> <map/> <max-field-size>0</max-field-size> <max-rows>0</max-rows> <query-timeout>0</query-timeout> <read-only>false</read-only> <rowset-type>TRANSACTION_READ_UNCOMMITTED</rowset-type> <show-deleted>false</show-deleted> <table-name/> <url>jdbc:thin:oracle</url> <sync-provider> <sync-provider-name>.com.rowset.provider.RIOptimisticProvider</sync-provider-name> <sync-provider-vendor>Oracle Corporation</sync-provider-vendor> <sync-provider-version>1.0</sync-provider-name> <sync-provider-grade>LOW</sync-provider-grade> <data-source-lock>NONE</data-source-lock> </sync-provider> </properties>column-definition标记之间描述了这两列。详细说明了属性和元数据的描述方式,下面详细说明了如何用XML描述<metadata> <column-count>2</column-count> <column-definition> <column-index>1</column-index> <auto-increment>false</auto-increment> <case-sensitive>true</case-sensitive> <currency>false</currency> <nullable>1</nullable> <signed>false</signed> <searchable>true</searchable> <column-display-size>10</column-display-size> <column-label>COL1</column-label> <column-name>COL1</column-name> <schema-name/> <column-precision>10</column-precision> <column-scale>0</column-scale> <table-name/> <catalog-name/> <column-type>1</column-type> <column-type-name>CHAR</column-type-name> </column-definition> <column-definition> <column-index>2</column-index> <auto-increment>false</auto-increment> <case-sensitive>false</case-sensitive> <currency>false</currency> <nullable>1</nullable> <signed>true</signed> <searchable>true</searchable> <column-display-size>39</column-display-size> <column-label>COL2</column-label> <column-name>COL2</column-name> <schema-name/> <column-precision>38</column-precision> <column-scale>0</column-scale> <table-name/> <catalog-name/> <column-type>3</column-type> <column-type-name>NUMBER</column-type-name> </column-definition> </metadata>WebRowSet对象的内容。 请注意,这描述了自实例化以来未经过任何修改的WebRowSet对象。currentRow标记映射到WebRowSet对象提供的表结构的每一行。 根据XML值映射回的SQL类型,columnValue标记可以包含stringData或binaryData标记。binaryData标记包含Base64编码的数据,通常用于BLOB和CLOB类型数据。<data> <currentRow> <columnValue> firstrow </columnValue> <columnValue> 1 </columnValue> </currentRow> <currentRow> <columnValue> secondrow </columnValue> <columnValue> 2 </columnValue> </currentRow> <currentRow> <columnValue> thirdrow </columnValue> <columnValue> 3 </columnValue> </currentRow> <currentRow> <columnValue> fourthrow </columnValue> <columnValue> 4 </columnValue> </currentRow> </data>2.2状态2 - 删除一行
删除WebRowSet对象中的行只需移动到要删除的行,然后调用方法deleteRow,就像在任何其他RowSet对象中一样。 以下两行代码,其中wrs是WebRowSet对象,删除第三行。wrs.absolute(3); wrs.deleteRow();XML描述显示第三行标记为deleteRow,这消除了WebRowSet对象中的第三行。<data> <currentRow> <columnValue> firstrow </columnValue> <columnValue> 1 </columnValue> </currentRow> <currentRow> <columnValue> secondrow </columnValue> <columnValue> 2 </columnValue> </currentRow> <deleteRow> <columnValue> thirdrow </columnValue> <columnValue> 3 </columnValue> </deleteRow> <currentRow> <columnValue> fourthrow </columnValue> <columnValue> 4 </columnValue> </currentRow> </data>2.3状态3 - 插入一行
WebRowSet对象可以通过移动到插入行来插入新行,为行中的每个列调用适当的更新程序方法,然后调用方法insertRow。以下代码片段更改刚刚插入的行中的第二列值。 请注意,当在当前行之后插入新行时,此代码适用,这就是方法wrs.moveToInsertRow(); wrs.updateString(1, "fifththrow"); wrs.updateString(2, "5"); wrs.insertRow();next将光标移动到正确行的原因。 调用方法acceptChanges将更改写入数据源。用XML描述这一点演示了Java代码在何处插入新行,然后对单个字段上新插入的行执行更新。wrs.moveToCurrentRow(); wrs.next(); wrs.updateString(2, "V"); wrs.acceptChanges();<data> <currentRow> <columnValue> firstrow </columnValue> <columnValue> 1 </columnValue> </currentRow> <currentRow> <columnValue> secondrow </columnValue> <columnValue> 2 </columnValue> </currentRow> <currentRow> <columnValue> newthirdrow </columnValue> <columnValue> III </columnValue> </currentRow> <insertRow> <columnValue> fifthrow </columnValue> <columnValue> 5 </columnValue> <updateValue> V </updateValue> </insertRow> <currentRow> <columnValue> fourthrow </columnValue> <columnValue> 4 </columnValue> </currentRow> </date>2.4国家4 - 修改一行
修改行会生成特定的XML,该XML记录新值和替换的值。 替换的值将成为原始值,新值将成为当前值。 以下代码将光标移动到特定行,执行一些修改,并在完成时更新行。在XML中,这由wrs.absolute(5); wrs.updateString(1, "new4thRow"); wrs.updateString(2, "IV"); wrs.updateRow();modifyRow标记描述。 原始行和新值都包含在标记中,用于原始行跟踪目的。<data> <currentRow> <columnValue> firstrow </columnValue> <columnValue> 1 </columnValue> </currentRow> <currentRow> <columnValue> secondrow </columnValue> <columnValue> 2 </columnValue> </currentRow> <currentRow> <columnValue> newthirdrow </columnValue> <columnValue> III </columnValue> </currentRow> <currentRow> <columnValue> fifthrow </columnValue> <columnValue> 5 </columnValue> </currentRow> <modifyRow> <columnValue> fourthrow </columnValue> <updateValue> new4thRow </updateValue> <columnValue> 4 </columnValue> <updateValue> IV </updateValue> </modifyRow> </data>- 从以下版本开始:
- 1.5
- 另请参见:
-
JdbcRowSet,CachedRowSet,FilteredRowSet,JoinRowSet
-
-
字段汇总
字段 变量和类型 字段 描述 static StringPUBLIC_XML_SCHEMAXML Schema定义的公共标识符,用于定义WebRowSet实现的XML标记及其有效值。static StringSCHEMA_SYSTEM_IDXML Schema定义文件的URL,用于定义WebRowSet实现的XML标记及其有效值。-
Fields declared in interface javax.sql.rowset.CachedRowSet
COMMIT_ON_ACCEPT_CHANGES
-
Fields declared in 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
-
-
方法摘要
所有方法 实例方法 抽象方法 变量和类型 方法 描述 voidreadXml(InputStream iStream)读取基于流的XML输入以填充此WebRowSet对象。voidreadXml(Reader reader)读取WebRowSet在从给定的XML格式对象Reader对象。voidwriteXml(OutputStream oStream)将此WebRowSet对象的数据,属性和元数据以XML格式写入给定的OutputStream对象。voidwriteXml(Writer writer)将此WebRowSet对象的数据,属性和元数据以XML格式写入给定的Writer对象。voidwriteXml(ResultSet rs, OutputStream oStream)使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据,属性和元数据以XML格式写入给定的OutputStream对象。voidwriteXml(ResultSet rs, Writer writer)使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据,属性和元数据以XML格式写入给定的Writer对象。-
声明方法的接口 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
-
声明方法的接口 javax.sql.rowset.Joinable
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn
-
声明方法的接口 java.sql.ResultSet
absolute, afterLast, beforeFirst, cancelRowUpdates, clearWarnings, close, deleteRow, findColumn, first, getArray, getArray, getAsciiStream, getAsciiStream, getBigDecimal, getBigDecimal, getBigDecimal, getBigDecimal, getBinaryStream, getBinaryStream, getBlob, getBlob, getBoolean, getBoolean, getByte, getByte, getBytes, getBytes, getCharacterStream, getCharacterStream, getClob, getClob, getConcurrency, getCursorName, getDate, getDate, getDate, getDate, getDouble, getDouble, getFetchDirection, getFetchSize, getFloat, getFloat, getHoldability, getInt, getInt, getLong, getLong, getMetaData, getNCharacterStream, getNCharacterStream, getNClob, getNClob, getNString, getNString, getObject, getObject, getObject, getObject, getObject, getObject, getRef, getRef, getRow, getRowId, getRowId, getShort, getShort, getSQLXML, getSQLXML, getStatement, getString, getString, getTime, getTime, getTime, getTime, getTimestamp, getTimestamp, getTimestamp, getTimestamp, getType, getUnicodeStream, getUnicodeStream, getURL, getURL, getWarnings, insertRow, isAfterLast, isBeforeFirst, isClosed, isFirst, isLast, last, moveToCurrentRow, moveToInsertRow, next, previous, refreshRow, relative, rowDeleted, rowInserted, rowUpdated, setFetchDirection, setFetchSize, updateArray, updateArray, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateAsciiStream, updateBigDecimal, updateBigDecimal, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBinaryStream, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBlob, updateBoolean, updateBoolean, updateByte, updateByte, updateBytes, updateBytes, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateCharacterStream, updateClob, updateClob, updateClob, updateClob, updateClob, updateClob, updateDate, updateDate, updateDouble, updateDouble, updateFloat, updateFloat, updateInt, updateInt, updateLong, updateLong, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNCharacterStream, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNClob, updateNString, updateNString, updateNull, updateNull, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateObject, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNull
-
声明方法的接口 javax.sql.RowSet
addRowSetListener, clearParameters, execute, getCommand, getDataSourceName, getEscapeProcessing, getMaxFieldSize, getMaxRows, getPassword, getQueryTimeout, getTransactionIsolation, getTypeMap, getUrl, getUsername, isReadOnly, removeRowSetListener, setArray, setAsciiStream, setAsciiStream, setAsciiStream, setAsciiStream, setBigDecimal, setBigDecimal, setBinaryStream, setBinaryStream, setBinaryStream, setBinaryStream, setBlob, setBlob, setBlob, setBlob, setBlob, setBlob, setBoolean, setBoolean, setByte, setByte, setBytes, setBytes, setCharacterStream, setCharacterStream, setCharacterStream, setCharacterStream, setClob, setClob, setClob, setClob, setClob, setClob, setCommand, setConcurrency, setDataSourceName, setDate, setDate, setDate, setDate, setDouble, setDouble, setEscapeProcessing, setFloat, setFloat, setInt, setInt, setLong, setLong, setMaxFieldSize, setMaxRows, setNCharacterStream, setNCharacterStream, setNCharacterStream, setNCharacterStream, setNClob, setNClob, setNClob, setNClob, setNClob, setNClob, setNString, setNString, setNull, setNull, setNull, setNull, setObject, setObject, setObject, setObject, setObject, setObject, setPassword, setQueryTimeout, setReadOnly, setRef, setRowId, setRowId, setShort, setShort, setSQLXML, setSQLXML, setString, setString, setTime, setTime, setTime, setTime, setTimestamp, setTimestamp, setTimestamp, setTimestamp, setTransactionIsolation, setType, setTypeMap, setUrl, setURL, setUsername
-
声明方法的接口 java.sql.Wrapper
isWrapperFor, unwrap
-
-
-
-
方法详细信息
-
readXml
void readXml(Reader reader) throws SQLException
读取WebRowSet在从给定的XML格式对象Reader对象。- 参数
-
reader- 将从中填充此WebRowSet对象的java.io.Reader流 - 异常
-
SQLException- 如果发生数据库访问错误
-
readXml
void readXml(InputStream iStream) throws SQLException, IOException
读取基于流的XML输入以填充此WebRowSet对象。- 参数
-
iStream-所述java.io.InputStream从中此WebRowSet对象将被填充 - 异常
-
SQLException- 如果发生数据源访问错误 -
IOException- 如果发生IO异常
-
writeXml
void writeXml(ResultSet rs, Writer writer) throws SQLException
使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据,属性和元数据以XML格式写入给定的Writer对象。注意:可以移动
WebRowSet游标以将内容写出到XML数据源。 如果以这种方式实现,则必须将光标返回到writeXml()调用之前的位置。- 参数
-
rs-该ResultSet对象与填充此WebRowSet对象 -
writer- 要写入的java.io.Writer对象。 - 异常
-
SQLException- 如果以XML格式写出行集内容时发生错误
-
writeXml
void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException
使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据,属性和元数据以XML格式写入给定的OutputStream对象。注意:可以移动
WebRowSet游标以将内容写出到XML数据源。 如果以这种方式实现,则必须将光标返回到writeXml()调用之前的位置。- 参数
-
rs-该ResultSet对象与填充此WebRowSet对象 -
oStream- 要写入的java.io.OutputStream - 异常
-
SQLException- 如果发生数据源访问错误 -
IOException- 如果发生IO异常
-
writeXml
void writeXml(Writer writer) throws SQLException
将此WebRowSet对象的数据,属性和元数据以XML格式写入给定的Writer对象。- 参数
-
writer- 要写入的java.io.Writer流 - 异常
-
SQLException- 如果在将行集内容写出到XML时发生错误
-
writeXml
void writeXml(OutputStream oStream) throws SQLException, IOException
将此WebRowSet对象的数据,属性和元数据以XML格式写入给定的OutputStream对象。- 参数
-
oStream- 要写入的java.io.OutputStream流 - 异常
-
SQLException- 如果发生数据源访问错误 -
IOException- 如果发生IO异常
-
-