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 ������ڲ����ݣ�

2.0 WebRowSet ״̬

���¼�������ʾ WebRowSet ʵ��Ӧ�����ʹ�� XML ģʽ���������¡������ɾ���������Լ����� XML �� WebRowSet �����״̬��

2.1 ״̬ 1 - �� WebRowSet �������Ϊ XML

�ڴ�ʾ���У�����һ�� WebRowSet ���󣬲�ʹ��ȡ������Դ��һ���򵥵� 2 �С�5 �б�������䡣���� WebRowSet �����е� 5 ����ʹ�� XML �������dz�Ϊ���ܡ������� 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>
 
��ϸ˵������������Ժ�Ԫ����֮��������ϸ˵�����ʹ�� XML ���� WebRowSet ��������ݡ�ע�⣬�����������Դ�ʵ��������û�о����κ��޸ĵ� WebRowSet ����currentRow ��ǽ���ӳ�䵽 WebRowSet �������ṩ�ı��ṹ��ÿһ���С�columnValue ��ǿ��ܰ��� stringData �� binaryData ��ǣ���ȡ���ڽ� XML ֵӳ��ص� SQL ���͡�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 ������д������Դ��
 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���� 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
          Ϊ WebRowSet ʵ�ֶ��� XML ��Ǽ�����Чֵ�� XML ģʽ����Ĺ�����ʶ����
static String SCHEMA_SYSTEM_ID
          Ϊ WebRowSet ʵ�ֶ��� XML ��Ǽ�����Чֵ�� 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)
          �� XML ��ʽ���� WebRowSet ��������ݡ����Ժ�Ԫ����д������� OutputStream ����
 void writeXml(ResultSet rs, OutputStream oStream)
          ʹ�ø��� ResultSet ������������� WebRowSet ���󣬲��� XML ��ʽ�������ݡ����Ժ�Ԫ����д������� OutputStream ����
 void writeXml(ResultSet rs, Writer writer)
          ʹ�ø��� ResultSet ������������� WebRowSet ���󣬲��� XML ��ʽ�������ݡ����Ժ�Ԫ����д������� Writer ����
 void writeXml(Writer writer)
          �� XML ��ʽ���� WebRowSet ��������ݡ����Ժ�Ԫ����д������� 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 �̳еķ���
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
Ϊ WebRowSet ʵ�ֶ��� XML ��Ǽ�����Чֵ�� XML ģʽ����Ĺ�����ʶ����

������
�����ֶ�ֵ

SCHEMA_SYSTEM_ID

static final String SCHEMA_SYSTEM_ID
Ϊ WebRowSet ʵ�ֶ��� XML ��Ǽ�����Чֵ�� XML ģʽ����� URL��

������
�����ֶ�ֵ
������ϸ��Ϣ

readXml

void readXml(Reader reader)
             throws SQLException
�Ӹ����� Reader �������� XML ��ʽ��ȡ WebRowSet ����

������
reader - �������� WebRowSet ����� java.io.Reader ����
�׳���
SQLException - ����������ݿ���ʴ���

readXml

void readXml(InputStream iStream)
             throws SQLException,
                    IOException
��ȡ�������� XML ���룬������ WebRowSet ����

������
iStream - �������� WebRowSet ����� java.io.InputStream
�׳���
SQLException - �����������Դ���ʴ���
IOException - ������� IO �쳣

writeXml

void writeXml(ResultSet rs,
              Writer writer)
              throws SQLException
ʹ�ø��� ResultSet ������������� WebRowSet ���󣬲��� XML ��ʽ�������ݡ����Ժ�Ԫ����д������� Writer ����

ע�������ƶ� WebRowSet ָ�뽫����д���� XML ����Դ�С���������ַ�ʽʵ�֣����ڵ��� writeXml() ֮ǰָ�������ȷ�����λ�á�

������
rs - �������� WebRowSet ����� ResultSet ����
writer - Ҫд��� java.io.Writer ����
�׳���
SQLException - ������� XML ��ʽд�� rowset ����ʱ��������

writeXml

void writeXml(ResultSet rs,
              OutputStream oStream)
              throws SQLException,
                     IOException
ʹ�ø��� ResultSet ������������� WebRowSet ���󣬲��� XML ��ʽ�������ݡ����Ժ�Ԫ����д������� OutputStream ����

ע�������ƶ� WebRowSet ָ�뽫����д���� XML ����Դ�С���������ַ�ʽʵ�֣����ڵ��� writeXml() ֮ǰ�����Ƚ�ָ�뷵����λ�á�

������
rs - �������� WebRowSet ����� ResultSet ����
oStream - Ҫд��� java.io.OutputStream
�׳���
SQLException - �����������Դ���ʴ���
IOException - ������� IO �쳣

writeXml

void writeXml(Writer writer)
              throws SQLException
�� XML ��ʽ���� WebRowSet ��������ݡ����Ժ�Ԫ����д������� Writer ����

������
writer - Ҫд��� java.io.Writer ��
�׳���
SQLException - ����ڽ� rowset ����д���� XML ʱ����

writeXml

void writeXml(OutputStream oStream)
              throws SQLException,
                     IOException
�� XML ��ʽ���� WebRowSet ��������ݡ����Ժ�Ԫ����д������� OutputStream ����

������
oStream - Ҫд��� java.io.OutputStream ��
�׳���
SQLException - �����������Դ���ʴ���
IOException - ������� IO �쳣

JavaTM Platform
Standard Ed. 6

�ύ��������
�йظ���� API �ο����ϺͿ�����Ա�ĵ�������� Java SE ������Ա�ĵ������ĵ���������ϸ�ġ����򿪷���Ա���������Լ�������������ﶨ�塢ʹ�ü��ɺ͹�������ʾ����

��Ȩ���� 2007 Sun Microsystems, Inc. ��������Ȩ���� ����������֤��������������ĵ����·ַ�������