JavaTM Platform
Standard Ed. 6

javax.sql.rowset
インタフェース WebRowSet

すべてのスーパーインタフェース:
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 スキーマ注釈を使用するので、プラットフォーム間の相互運用性がさらに向上します。なお、このスキーマ定義は、ISO 内で現在開発中です。SQL/XML 定義は、次の URI で確認できます。 このスキーマ定義は、RowSet オブジェクトの内部データを次の 3 つの領域から記述します。

2.0 WebRowSet の状態

次に、WebRowSet 実装で、XML スキーマを使用して、更新、挿入、または削除操作を記述し、XML での WebRowSet オブジェクトの状態を記述する方法について具体的に説明します。

2.1 状態 1 - WebRowSet オブジェクトの XML での出力

この例では、WebRowSet オブジェクトが、データソースから、2 列 × 5 行の単純な表形式で生成されます。WebRowSet オブジェクトに 5 行あるため、それらを XML で記述できます。RowSet インタフェースに定義されたさまざまな標準 JavaBeans プロパティーと、CachedRowSetTM インタフェースに定義された標準プロパティーとを記述するメタデータにより、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_UNCOMMITED</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>Sun Microsystems</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 行のコード (この中では wrsWebRowSet オブジェクト) で 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>
 

関連項目:
JdbcRowSet, CachedRowSet, FilteredRowSet, JoinRowSet

フィールドの概要
static String PUBLIC_XML_SCHEMA
          XML タグと、これらの XML タグの WebRowSet 実装での有効値を定義する、XML スキーマ定義の公開識別子です。
static String SCHEMA_SYSTEM_ID
          XML タグと、これらの XML タグの WebRowSet 実装での有効値を定義する、XML スキーマ定義の URL です。
 
インタフェース javax.sql.rowset.CachedRowSet から継承されたフィールド
COMMIT_ON_ACCEPT_CHANGES
 
インタフェース 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
 
メソッドの概要
 void readXml(InputStream iStream)
          ストリームベースの XML 入力を読み込み、WebRowSet オブジェクトを生成します。
 void readXml(Reader reader)
          指定された Reader オブジェクトから、XML 形式で WebRowSet オブジェクトを読み取ります。
 void writeXml(OutputStream oStream)
          この WebRowSet オブジェクトのデータ、プロパティー、メタデータを指定された OutputStream オブジェクトに XML 形式で書き込みます。
 void writeXml(ResultSet rs, OutputStream oStream)
          指定された ResultSet オブジェクトのコンテンツからこの WebRowSet オブジェクトを生成し、そのデータ、プロパティー、およびメタデータを指定された OutputStream オブジェクトに XML 形式で書き込みます。
 void writeXml(ResultSet rs, Writer writer)
          指定された ResultSet オブジェクトのコンテンツからこの WebRowSet オブジェクトを生成し、そのデータ、プロパティー、およびメタデータを指定された Writer オブジェクトに XML 形式で書き込みます。
 void writeXml(Writer writer)
          この 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 から継承されたメソッド
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.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, 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, updateRef, updateRef, updateRow, updateRowId, updateRowId, updateShort, updateShort, updateSQLXML, updateSQLXML, updateString, updateString, updateTime, updateTime, updateTimestamp, updateTimestamp, wasNull
 
インタフェース java.sql.Wrapper から継承されたメソッド
isWrapperFor, unwrap
 
インタフェース javax.sql.rowset.Joinable から継承されたメソッド
getMatchColumnIndexes, getMatchColumnNames, setMatchColumn, setMatchColumn, setMatchColumn, setMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn, unsetMatchColumn
 

フィールドの詳細

PUBLIC_XML_SCHEMA

static final String PUBLIC_XML_SCHEMA
XML タグと、これらの XML タグの WebRowSet 実装での有効値を定義する、XML スキーマ定義の公開識別子です。

関連項目:
定数フィールド値

SCHEMA_SYSTEM_ID

static final String SCHEMA_SYSTEM_ID
XML タグと、これらの 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 例外が発生した場合

JavaTM Platform
Standard Ed. 6

バグの報告と機能のリクエスト
さらに詳しい API リファレンスおよび開発者ドキュメントについては、Java SE 開発者用ドキュメントを参照してください。開発者向けの詳細な解説、概念の概要、用語の定義、バグの回避策、およびコード実例が含まれています。

Copyright 2009 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Documentation Redistribution Policy も参照してください。