- 所有父级接口:
AutoCloseable,CachedRowSet,Joinable,ResultSet,RowSet,Wrapper
- 所有已知的子接口:
FilteredRowSet,JoinRowSet
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接口中可访问的元数据密切相关。 - 数据 - 这描述了原始数据(自上次填充或上次同步
WebRowSet对象以来的数据状态)和当前数据。通过跟踪原始数据和当前数据之间的增量,WebRowSet保持将其数据中的更改同步回原始数据源的能力。
2.0 WebRowSet 状态
以下部分演示了WebRowSet 实现应如何使用 XML 架构来描述更新、插入和删除操作以及如何在 XML 中描述 WebRowSet 对象的状态。
2.1 状态 1 - 将 WebRowSet 对象输出到 XML
在此示例中,创建了一个 WebRowSet 对象,并使用来自数据源的一个简单的 2 列 5 行表进行填充。在 WebRowSet 对象中包含 5 行使得用 XML 描述它们成为可能。描述 RowSet 接口中定义的各种标准 JavaBeans 属性的元数据以及 CachedRowSet 接口中定义的标准属性提供了描述 WebRowSet 属性的关键细节。使用标准 writeXml 方法将 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>
描述 WebRowSet 组成的元数据在 XML 中进行了详细描述,如下所述。请注意,这两列都在 column-definition 标记之间进行了描述。
<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对象的内容是如何用XML描述的。请注意,这描述了一个 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 状态三——插入一行
WebRowSet 对象可以通过移动到插入行来插入新行,为行中的每一列调用适当的更新方法,然后调用方法 insertRow 。
wrs.moveToInsertRow();
wrs.updateString(1, "fifththrow");
wrs.updateString(2, "5");
wrs.insertRow();
以下代码片段更改刚刚插入的行中的第二列值。请注意,当新行插入到当前行之后时,此代码适用,这就是方法 next 将光标移动到正确行的原因。调用方法 acceptChanges 将更改写入数据源。
wrs.moveToCurrentRow();
wrs.next();
wrs.updateString(2, "V");
wrs.acceptChanges();
在 XML 中对此进行描述演示了 Java 代码在何处插入新行,然后对单个字段上新插入的行执行更新。
<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,其中记录了新值和被替换的值。被替换的值成为原始值,新值成为当前值。以下代码将光标移动到特定行,执行一些修改,并在完成时更新该行。
wrs.absolute(5);
wrs.updateString(1, "new4thRow");
wrs.updateString(2, "IV");
wrs.updateRow();
在 XML 中,这由 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
- 参见:
-
字段摘要
字段修饰符和类型Field描述static final String为WebRowSet实现定义 XML 标记及其有效值的 XML 模式定义的公共标识符。static final String为WebRowSet实现定义 XML 标记及其有效值的 XML 架构定义文件的 URL。在接口 javax.sql.rowset.CachedRowSet 中声明的字段
COMMIT_ON_ACCEPT_CHANGES -
方法总结
修饰符和类型方法描述voidreadXml(InputStream iStream) 读取基于流的 XML 输入以填充此WebRowSet对象。void从给定的Reader对象中读取 XML 格式的WebRowSet对象。voidwriteXml(OutputStream oStream) 以 XML 格式将此WebRowSet对象的数据、属性和元数据写入给定的OutputStream对象。void以 XML 格式将此WebRowSet对象的数据、属性和元数据写入给定的Writer对象。voidwriteXml(ResultSet rs, OutputStream oStream) 使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据、属性和元数据以 XML 格式写入给定的OutputStream对象。void使用给定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
-
字段详细信息
-
PUBLIC_XML_SCHEMA
为WebRowSet实现定义 XML 标记及其有效值的 XML 模式定义的公共标识符。- 参见:
-
SCHEMA_SYSTEM_ID
为WebRowSet实现定义 XML 标记及其有效值的 XML 架构定义文件的 URL。- 参见:
-
-
方法详情
-
readXml
从给定的Reader对象中读取 XML 格式的WebRowSet对象。- 参数:
reader- 将从中填充此WebRowSet对象的java.io.Reader流- 抛出:
SQLException- 如果发生数据库访问错误
-
readXml
读取基于流的 XML 输入以填充此WebRowSet对象。- 参数:
iStream- 将从中填充此WebRowSet对象的java.io.InputStream- 抛出:
SQLException- 如果发生数据源访问错误IOException- 如果发生 IO 异常
-
writeXml
使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据、属性和元数据以 XML 格式写入给定的Writer对象。注意:可以移动
WebRowSet光标以将内容写出到 XML 数据源。如果以这种方式实现,游标必须返回到它在writeXml()调用之前的位置。- 参数:
rs- 用于填充此WebRowSet对象的ResultSet对象writer- 要写入的java.io.Writer对象。- 抛出:
SQLException- 如果以 XML 格式写出行集内容时发生错误
-
writeXml
使用给定ResultSet对象的内容填充此WebRowSet对象,并将其数据、属性和元数据以 XML 格式写入给定的OutputStream对象。注意:可以移动
WebRowSet光标以将内容写出到 XML 数据源。如果以这种方式实现,游标必须返回到它在writeXml()调用之前的位置。- 参数:
rs- 用于填充此WebRowSet对象的ResultSet对象oStream- 要写入的java.io.OutputStream- 抛出:
SQLException- 如果发生数据源访问错误IOException- 如果发生 IO 异常
-
writeXml
以 XML 格式将此WebRowSet对象的数据、属性和元数据写入给定的Writer对象。- 参数:
writer- 要写入的java.io.Writer流- 抛出:
SQLException- 如果将行集内容写入 XML 时发生错误
-
writeXml
以 XML 格式将此WebRowSet对象的数据、属性和元数据写入给定的OutputStream对象。- 参数:
oStream- 要写入的java.io.OutputStream流- 抛出:
SQLException- 如果发生数据源访问错误IOException- 如果发生 IO 异常
-