- すべてのスーパー・インタフェース:
AutoCloseable,CachedRowSet,Joinable,ResultSet,RowSet,Wrapper
- 既知のすべてのサブインタフェース:
FilteredRowSet,JoinRowSet
public interface WebRowSet extends CachedRowSet
WebRowSetのすべての実装が実装しなければならない標準インタフェースです。
1.0 概要
WebRowSetImplは、必要に応じて拡張可能な標準リファレンス実装を提供します。
標準WebRowSet XMLスキーマ定義は、次のURIで確認できます。
このスキーマ定義は、XMLでRowSetを記述するときに必要な標準XMLドキュメント形式について記述したものです。相互運用性を得るためには、WebRowSetインタフェースのすべての標準実装で、このスキーマ定義を使用する必要があります。 さらに、WebRowSetスキーマは特定のSQL/XML Schema注釈を使用しているため、クロス・プラットフォームの相互運用性が向上します。 なお、このスキーマ定義は、ISO内で現在開発中です。 SQL/XML定義は、次のURIで確認できます。
このスキーマ定義は、RowSetオブジェクトの内部データを次の3つの領域から記述します。
- properties - 一般的な
RowSetプロパティに加えて、標準同期プロバイダのプロパティを記述する。 - metadata -
WebRowSetオブジェクトの管理下にある表構造に関連付けられたメタデータについて記述する。 記述されるメタデータは、配下のjava.sql.ResultSetインタフェース内でアクセス可能なメタデータと密接に連携している。 - data - 元のデータ(前回
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オブジェクトの表構造の各行に対応しています。 columnValueタグには、XML値のマップ先のSQL型によって、stringDataまたはbinaryDataタグが入ります。 binaryDataタグは通常、BLOBまたはCLOB型データ用です。ここには、Base64エンコード方式のデータが入ります。
<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オブジェクトの行の削除では、ほかのRowSetオブジェクトと同様に、単に削除する行に移動し、deleteRowメソッドを呼び出すだけです。 次の2行のコード(この中ではwrsがWebRowSetオブジェクト)で3行目を削除します。
wrs.absolute(3);
wrs.deleteRow();
XMLの記述では、3行目にdeleteRowというマークが付きWebRowSetオブジェクトの3行目が排除されます。
<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();
次のコードの抜粋では、挿入したばかりの行の2列目の値を変更しています。 このコードは、現在の行の直後に新しい行が挿入された場合に適用されます。このため、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
- 関連項目:
JdbcRowSet、CachedRowSet、FilteredRowSet、JoinRowSet
-
フィールドのサマリー
フィールド 修飾子と型 フィールド 説明 static StringPUBLIC_XML_SCHEMAXMLタグと、これらのXMLタグのWebRowSet実装での有効値を定義する、XMLスキーマ定義の公開識別子です。static StringSCHEMA_SYSTEM_IDXMLタグと、これらのXMLタグのWebRowSet実装での有効値を定義する、XMLスキーマ定義のURLです。インタフェース 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)指定されたReaderオブジェクトから、XML形式でWebRowSetオブジェクトを読み取ります。voidwriteXml(OutputStream oStream)このWebRowSetオブジェクトのデータ、プロパティ、メタデータを指定されたOutputStreamオブジェクトにXML形式で書き込みます。voidwriteXml(Writer writer)このWebRowSetオブジェクトのデータ、プロパティ、メタデータを指定されたWriterオブジェクトにXML形式で書き込みます。voidwriteXml(ResultSet rs, OutputStream oStream)指定されたResultSetオブジェクトの内容からこのWebRowSetオブジェクトを生成し、そのデータ、プロパティ、およびメタデータを指定されたOutputStreamオブジェクトにXML形式で書き込みます。voidwriteXml(ResultSet rs, Writer writer)指定されたResultSetオブジェクトの内容からこのWebRowSetオブジェクトを生成し、そのデータ、プロパティ、およびメタデータを指定されたWriterオブジェクトにXML形式で書き込みます。インタフェース 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
-
フィールド詳細
-
PUBLIC_XML_SCHEMA
static final String PUBLIC_XML_SCHEMAXMLタグと、これらのXMLタグのWebRowSet実装での有効値を定義する、XMLスキーマ定義の公開識別子です。- 関連項目:
- 定数フィールド値
-
SCHEMA_SYSTEM_ID
static final String SCHEMA_SYSTEM_IDXMLタグと、これらのXMLタグのWebRowSet実装での有効値を定義する、XMLスキーマ定義のURLです。- 関連項目:
- 定数フィールド値
-
-
メソッドの詳細
-
readXml
void readXml(Reader reader) throws SQLException指定されたReaderオブジェクトから、XML形式でWebRowSetオブジェクトを読み取ります。- パラメータ:
reader-java.io.Readerストリーム。ここからWebRowSetオブジェクトが生成される- 例外:
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オブジェクトを生成し、そのデータ、プロパティ、およびメタデータを指定されたWriterオブジェクトにXML形式で書き込みます。注:
WebRowSetカーソルは、XMLデータ・ソースへコンテンツを書き出すために移動するかもしれません。 このように実装されている場合、カーソルを、writeXml()呼出しの直前の位置に戻す必要があります。- パラメータ:
rs- このWebRowSetオブジェクトを生成するResultSetオブジェクトwriter- 書き込むjava.io.Writerオブジェクト。- 例外:
SQLException- 行セットのコンテンツをXML形式で書き出すときにエラーが発生した場合
-
writeXml
void writeXml(ResultSet rs, OutputStream oStream) throws SQLException, IOException指定されたResultSetオブジェクトの内容からこのWebRowSetオブジェクトを生成し、そのデータ、プロパティ、およびメタデータを指定されたOutputStreamオブジェクトにXML形式で書き込みます。注:
WebRowSetカーソルは、XMLデータ・ソースへコンテンツを書き出すために移動するかもしれません。 このように実装されている場合、カーソルを、writeXml()呼出しの直前の位置に戻す必要があります。- パラメータ:
rs- このWebRowSetオブジェクトを生成するResultSetオブジェクトoStream- 書込み先のjava.io.OutputStream- 例外:
SQLException- データ・ソース・アクセス・エラーが発生した場合IOException- IO例外が発生した場合
-
writeXml
void writeXml(Writer writer) throws SQLExceptionこのWebRowSetオブジェクトのデータ、プロパティ、メタデータを指定されたWriterオブジェクトにXML形式で書き込みます。- パラメータ:
writer- 書込み先のjava.io.Writerストリーム- 例外:
SQLException- 行セットのコンテンツをXMLへ書き出すときにエラーが発生した場合
-
writeXml
void writeXml(OutputStream oStream) throws SQLException, IOExceptionこのWebRowSetオブジェクトのデータ、プロパティ、メタデータを指定されたOutputStreamオブジェクトにXML形式で書き込みます。- パラメータ:
oStream- 書込み先のjava.io.OutputStreamストリーム- 例外:
SQLException- データ・ソース・アクセス・エラーが発生した場合IOException- IO例外が発生した場合
-