The standard interface that all implementations of a WebRowSet must implement.

1.0 Overview

The WebRowSetImpl provides the standard reference implementation, which may be extended if required.

The standard WebRowSet XML Schema definition is available at the following URI:

It describes the standard XML document format required when describing a RowSet object in XML and must be used be all standard implementations of the WebRowSet interface to ensure interoperability. In addition, the WebRowSet schema uses specific SQL/XML Schema annotations, thus ensuring greater cross platform inter-operability. This is an effort currently under way at the ISO organization. The SQL/XML definition is available at the following URI: The schema definition describes the internal data of a RowSet object in three distinct areas:

2.0 WebRowSet States

The following sections demonstrates how a WebRowSet implementation should use the XML Schema to describe update, insert, and delete operations and to describe the state of a WebRowSet object in XML.

2.1 State 1 - Outputting a WebRowSet Object to XML

In this example, a WebRowSet object is created and populated with a simple 2 column, 5 row table from a data source. Having the 5 rows in a WebRowSet object makes it possible to describe them in XML. The metadata describing the various standard JavaBeans properties as defined in the RowSet interface plus the standard properties defined in the CachedRowSetTM interface provide key details that describe WebRowSet properties. Outputting the WebRowSet object to XML using the standard writeXml methods describes the internal properties as follows:
 <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> 
 
The meta-data describing the make up of the WebRowSet is described in XML as detailed below. Note both columns are described between the column-definition tags.
 <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>
 
Having detailed how the properties and metadata are described, the following details how the contents of a WebRowSet object is described in XML. Note, that this describes a WebRowSet object that has not undergone any modifications since its instantiation. A currentRow tag is mapped to each row of the table structure that the WebRowSet object provides. A columnValue tag may contain either the stringData or binaryData tag, according to the SQL type that the XML value is mapping back to. The binaryData tag contains data in the Base64 encoding and is typically used for BLOB and CLOB type data.
 <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 State 2 - Deleting a Row

Deleting a row in a WebRowSet object involves simply moving to the row to be deleted and then calling the method deleteRow, as in any other RowSet object. The following two lines of code, in which wrs is a WebRowSet object, delete the third row.
     wrs.absolute(3);
     wrs.deleteRow();
 
The XML description shows the third row is marked as a deleteRow, which eliminates the third row in the WebRowSet object.
 <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 State 3 - Inserting a Row

A object can insert a new row by moving to the insert row, calling the appropriate updater methods for each column in the row, and then calling the method insertRow.
 wrs.moveToInsertRow();
 wrs.updateString(1, "fifththrow");
 wrs.updateString(2, "5");
 wrs.insertRow();
 
The following code fragment changes the second column value in the row just inserted. Note that this code applies when new rows are inserted right after the current row, which is why the method next moves the cursor to the correct row. Calling the method acceptChanges writes the change to the data source.
 wrs.moveToCurrentRow();
 wrs.next();
 wrs.updateString(2, "V");
 wrs.acceptChanges();
 :
 
Describing this in XML demonstrates where the Java code inserts a new row and then performs an update on the newly inserted row on an individual field.
 
 <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 State 4 - Modifying a Row

Modifying a row produces specific XML that records both the new value and the value that was replaced. The value that was replaced becomes the original value, and the new value becomes the current value. The following code moves the cursor to a specific row, performs some modifications, and updates the row when complete.
 wrs.absolute(5);
 wrs.updateString(1, "new4thRow");
 wrs.updateString(2, "IV");
 wrs.updateRow();
 
In XML, this is described by the modifyRow tag. Both the original and new values are contained within the tag for original row tracking purposes.
 <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>
 
Causes the CachedRowSet object's SyncProvider to commit the changes when acceptChanges() is called. If set to false, the changes will not be committed until one of the CachedRowSet interface transaction methods is called.
See Also
The public identifier for the XML Schema definition that defines the XML tags and their valid values for a WebRowSet implementation.
The URL for the XML Schema definition file that defines the XML tags and their valid values for a WebRowSet implementation.
Propagates row update, insert and delete changes made to this CachedRowSet object to the underlying data source.

This method calls on this CachedRowSet object's writer to do the work behind the scenes. Standard CachedRowSet implementations should use the SyncFactory singleton to obtain a SyncProvider instance providing a RowSetWriter object (writer). The writer will attempt to propagate changes made in this CachedRowSet object back to the data source.

When the method acceptChanges executes successfully, in addition to writing changes to the data source, it makes the values in the current row be the values in the original row.

Depending on the synchronization level of the SyncProvider implementation being used, the writer will compare the original values with those in the data source to check for conflicts. When there is a conflict, the RIOptimisticProvider implementation, for example, throws a SyncProviderException and does not write anything to the data source.

An application may choose to catch the SyncProviderException object and retrieve the SyncResolver object it contains. The SyncResolver object lists the conflicts row by row and sets a lock on the data source to avoid further conflicts while the current conflicts are being resolved. Further, for each conflict, it provides methods for examining the conflict and setting the value that should be persisted in the data source. After all conflicts have been resolved, an application must call the acceptChanges method again to write resolved values to the data source. If all of the values in the data source are already the values to be persisted, the method acceptChanges does nothing.

Some provider implementations may use locks to ensure that there are no conflicts. In such cases, it is guaranteed that the writer will succeed in writing changes to the data source when the method acceptChanges is called. This method may be called immediately after the methods updateRow, insertRow, or deleteRow have been called, but it is more efficient to call it only once after all changes have been made so that only one connection needs to be established.

Note: The acceptChanges() method will determine if the COMMIT_ON_ACCEPT_CHANGES is set to true or not. If it is set to true, all updates in the synchronization are committed to the data source. Otherwise, the application must explicity call the commit() or rollback() methods as appropriate.

Throws
SQLExceptionif the cursor is on the insert row
SyncProviderExceptionif the underlying synchronization provider's writer fails to write the updates back to the data source
Propagates all row update, insert and delete changes to the data source backing this CachedRowSet object using the specified Connection object to establish a connection to the data source.

The other version of the acceptChanges method is not passed a connection because it uses the Connection object already defined within the RowSet object, which is the connection used for populating it initially.

This form of the method acceptChanges is similar to the form that takes no arguments; however, unlike the other form, this form can be used only when the underlying data source is a JDBC data source. The updated Connection properties must be used by the SyncProvider to reset the RowSetWriter configuration to ensure that the contents of the CachedRowSet object are synchronized correctly.

When the method acceptChanges executes successfully, in addition to writing changes to the data source, it makes the values in the current row be the values in the original row.

Depending on the synchronization level of the SyncProvider implementation being used, the writer will compare the original values with those in the data source to check for conflicts. When there is a conflict, the RIOptimisticProvider implementation, for example, throws a SyncProviderException and does not write anything to the data source.

An application may choose to catch the SyncProviderException object and retrieve the SyncResolver object it contains. The SyncResolver object lists the conflicts row by row and sets a lock on the data source to avoid further conflicts while the current conflicts are being resolved. Further, for each conflict, it provides methods for examining the conflict and setting the value that should be persisted in the data source. After all conflicts have been resolved, an application must call the acceptChanges method again to write resolved values to the data source. If all of the values in the data source are already the values to be persisted, the method acceptChanges does nothing.

Some provider implementations may use locks to ensure that there are no conflicts. In such cases, it is guaranteed that the writer will succeed in writing changes to the data source when the method acceptChanges is called. This method may be called immediately after the methods updateRow, insertRow, or deleteRow have been called, but it is more efficient to call it only once after all changes have been made so that only one connection needs to be established.

Note: The acceptChanges() method will determine if the COMMIT_ON_ACCEPT_CHANGES is set to true or not. If it is set to true, all updates in the synchronization are committed to the data source. Otherwise, the application must explicity call the commit or rollback methods as appropriate.

Parameters
cona standard JDBC Connection object
Throws
SQLExceptionif the cursor is on the insert row
SyncProviderExceptionif the underlying synchronization provider's writer fails to write the updates back to the data source
Indicates whether the designated column in the current row of this CachedRowSet object has been updated.
Parameters
idxan int identifying the column to be checked for updates
Return
true if the designated column has been visibly updated; false otherwise
Throws
SQLExceptionif the cursor is on the insert row, before the first row, or after the last row
Indicates whether the designated column in the current row of this CachedRowSet object has been updated.
Parameters
columnNamea String object giving the name of the column to be checked for updates
Return
true if the column has been visibly updated; false otherwise
Throws
SQLExceptionif the cursor is on the insert row, before the first row, or after the last row
Each CachedRowSet object's SyncProvider contains a Connection object from the ResultSet or JDBC properties passed to it's constructors. This method wraps the Connection commit method to allow flexible auto commit or non auto commit transactional control support.

Makes all changes that are performed by the acceptChanges() method since the previous commit/rollback permanent. This method should be used only when auto-commit mode has been disabled.

Throws
SQLExceptionif a database access error occurs or this Connection object within this CachedRowSet is in auto-commit mode
Creates a RowSet object that is a deep copy of the data in this CachedRowSet object. In contrast to the RowSet object generated from a createShared call, updates made to the copy of the original RowSet object must not be visible to the original RowSet object. Also, any event listeners that are registered with the original RowSet must not have scope over the new RowSet copies. In addition, any constraint restrictions established must be maintained.
Return
a new RowSet object that is a deep copy of this CachedRowSet object and is completely independent of this CachedRowSet object
Throws
SQLExceptionif an error occurs in generating the copy of the of this CachedRowSet object
Creates a CachedRowSet object that is a deep copy of this CachedRowSet object's data but is independent of it. In contrast to the RowSet object generated from a createShared method call, updates made to a copy of this CachedRowSet object must not be visible to it. Also, any event listeners that are registered with this CachedRowSet object must not have scope over the new RowSet object. In addition, any constraint restrictions established for this CachedRowSet object must not be maintained in the copy.
Return
a new CachedRowSet object that is a deep copy of this CachedRowSet object and is completely independent of this CachedRowSet object
Throws
SQLExceptionif an error occurs in generating the copy of the of this CachedRowSet object
Creates a CachedRowSet object that is an empty copy of this CachedRowSet object. The copy must not contain any contents but only represent the table structure of the original CachedRowSet object. In addition, primary or foreign key constraints set in the originating CachedRowSet object must be equally enforced in the new empty CachedRowSet object. In contrast to the RowSet object generated from a createShared method call, updates made to a copy of this CachedRowSet object with the createCopySchema method must not be visible to it.

Applications can form a WebRowSet object from the CachedRowSet object returned by this method in order to export the RowSet schema definition to XML for future use.

Throws
SQLExceptionif an error occurs in cloning the structure of this CachedRowSet object
Returns a new RowSet object backed by the same data as that of this CachedRowSet object. In effect, both CachedRowSet objects have a cursor over the same data. As a result, any changes made by a duplicate are visible to the original and to any other duplicates, just as a change made by the original is visible to all of its duplicates. If a duplicate calls a method that changes the underlying data, the method it calls notifies all registered listeners just as it would when it is called by the original CachedRowSet object.

In addition, any RowSet object created by this method will have the same properties as this CachedRowSet object. For example, if this CachedRowSet object is read-only, all of its duplicates will also be read-only. If it is changed to be updatable, the duplicates also become updatable.

NOTE: If multiple threads access RowSet objects created from the createShared() method, the following behavior is specified to preserve shared data integrity: reads and writes of all shared RowSet objects should be made serially between each object and the single underlying tabular structure.

Return
a new shared RowSet object that has the same properties as this CachedRowSet object and that has a cursor over the same data
Throws
SQLExceptionif an error occurs or cloning is not supported in the underlying platform
Populates this CachedRowSet object with data, using the given connection to produce the result set from which the data will be read. This method should close any database connections that it creates to ensure that this CachedRowSet object is disconnected except when it is reading data from its data source or writing data to its data source.

The reader for this CachedRowSet object will use conn to establish a connection to the data source so that it can execute the rowset's command and read data from the the resulting ResultSet object into this CachedRowSet object. This method also closes conn after it has populated this CachedRowSet object.

If this method is called when an implementation has already been populated, the contents and the metadata are (re)set. Also, if this method is called before the method acceptChanges has been called to commit outstanding updates, those updates are lost.

Parameters
conna standard JDBC Connection object with valid properties
Throws
SQLExceptionif an invalid Connection object is supplied or an error occurs in establishing the connection to the data source
Returns an array containing one or more column numbers indicating the columns that form a key that uniquely identifies a row in this CachedRowSet object.
Return
an array containing the column number or numbers that indicate which columns constitute a primary key for a row in this CachedRowSet object. This array should be empty if no columns are representative of a primary key.
Throws
SQLExceptionif this CachedRowSet object is empty
Returns a ResultSet object containing the original value of this CachedRowSet object.

The cursor for the ResultSet object should be positioned before the first row. In addition, the returned ResultSet object should have the following properties:

  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.CONCUR_UPDATABLE

The original value for a RowSet object is the value it had before the last synchronization with the underlying data source. If there have been no synchronizations, the original value will be the value with which the RowSet object was populated. This method is called internally when an aplication calls the method acceptChanges and the SyncProvider object has been implemented to check for conflicts. If this is the case, the writer compares the original value with the value currently in the data source to check for conflicts.

Return
a ResultSet object that contains the original value for this CachedRowSet object
Throws
SQLExceptionif an error occurs producing the ResultSet object
Returns a ResultSet object containing the original value for the current row only of this CachedRowSet object.

The cursor for the ResultSet object should be positioned before the first row. In addition, the returned ResultSet object should have the following properties:

  • ResultSet.TYPE_SCROLL_INSENSITIVE
  • ResultSet.CONCUR_UPDATABLE
Return
the original result set of the row
Throws
SQLExceptionif there is no current row
Returns the page-size for the CachedRowSet object
Return
an int page size
Retrieves the first warning reported by calls on this RowSet object. Subsequent warnings on this RowSet object will be chained to the RowSetWarning object that this method returns. The warning chain is automatically cleared each time a new row is read. This method may not be called on a RowSet object that has been closed; doing so will cause a SQLException to be thrown.
Return
RowSetWarning the first RowSetWarning object reported or null if there are none
Throws
SQLExceptionif this method is called on a closed RowSet
See Also
Retrieves a boolean indicating whether rows marked for deletion appear in the set of current rows. If true is returned, deleted rows are visible with the current rows. If false is returned, rows are not visible with the set of current rows. The default value is false.

Standard rowset implementations may choose to restrict this behavior due to security considerations or to better fit certain deployment scenarios. This is left as implementation defined and does not represent standard behavior.

Note: Allowing deleted rows to remain visible complicates the behavior of some standard JDBC RowSet Implementations methods. However, most rowset users can simply ignore this extra detail because only very specialized applications will likely want to take advantage of this feature.

Return
true if deleted rows are visible; false otherwise
Throws
SQLExceptionif a rowset implementation is unable to to determine whether rows marked for deletion are visible
Retrieves the SyncProvider implementation for this CachedRowSet object. Internally, this method is used by a rowset to trigger read or write actions between the rowset and the data source. For example, a rowset may need to get a handle on the the rowset reader (RowSetReader object) from the SyncProvider to allow the rowset to be populated.
     RowSetReader rowsetReader = null;
     SyncProvider provider = 
         SyncFactory.getInstance("javax.sql.rowset.provider.RIOptimisticProvider");
         if (provider instanceof RIOptimisticProvider) {
             rowsetReader = provider.getRowSetReader();
         }
 
Assuming rowsetReader is a private, accessible field within the rowset implementation, when an application calls the execute method, it in turn calls on the reader's readData method to populate the RowSet object.
    
     rowsetReader.readData((RowSetInternal)this);
 

In addition, an application can use the SyncProvider object returned by this method to call methods that return information about the SyncProvider object, including information about the vendor, version, provider identification, synchronization grade, and locks it currently has set.

Return
the SyncProvider object that was set when the rowset was instantiated, or if none was was set, the default provider
Throws
SQLExceptionif an error occurs while returning the SyncProvider object
Returns an identifier for the object (table) that was used to create this CachedRowSet object. This name may be set on multiple occasions, and the specification imposes no limits on how many times this may occur or whether standard implementations should keep track of previous table names.
Return
a String object giving the name of the table that is the source of data for this CachedRowSet object or null if no name has been set for the table
Throws
SQLExceptionif an error is encountered returning the table name
Increments the current page of the CachedRowSet. This causes the CachedRowSet implementation to fetch the next page-size rows and populate the RowSet, if remaining rows remain within scope of the original SQL query used to populated the RowSet.
Return
true if more pages exist; false if this is the last page
Throws
SQLExceptionif an error occurs fetching the next page, or if this method is called prematurely before populate or execute.
Populates this CachedRowSet object with data from the given ResultSet object.

This method can be used as an alternative to the execute method when an application has a connection to an open ResultSet object. Using the method populate can be more efficient than using the version of the execute method that takes no parameters because it does not open a new connection and re-execute this CachedRowSet object's command. Using the populate method is more a matter of convenience when compared to using the version of execute that takes a ResultSet object.

Parameters
datathe ResultSet object containing the data to be read into this CachedRowSet object
Throws
SQLExceptionif a null ResultSet object is supplied or this CachedRowSet object cannot retrieve the associated ResultSetMetaData object
Populates this CachedRowSet object with data from the given ResultSet object. While related to the populate(ResultSet) method, an additional parameter is provided to allow starting position within the ResultSet from where to populate the CachedRowSet instance.

This method can be used as an alternative to the execute method when an application has a connection to an open ResultSet object. Using the method populate can be more efficient than using the version of the execute method that takes no parameters because it does not open a new connection and re-execute this CachedRowSet object's command. Using the populate method is more a matter of convenience when compared to using the version of execute that takes a ResultSet object.

Parameters
startRowthe
rsthe ResultSet object containing the data to be read into this CachedRowSet object
Throws
SQLExceptionif a null ResultSet object is supplied or this CachedRowSet object cannot retrieve the associated ResultSetMetaData object
Decrements the current page of the CachedRowSet. This causes the CachedRowSet implementation to fetch the previous page-size rows and populate the RowSet. The amount of rows returned in the previous page must always remain within scope of the original SQL query used to populate the RowSet.
Return
true if the previous page is successfully retrieved; false if this is the first page.
Throws
SQLExceptionif an error occurs fetching the previous page, or if this method is called prematurely before populate or execute.
Reads a stream based XML input to populate this WebRowSet object.
Parameters
iStreamthe java.io.InputStream from which this WebRowSet object will be populated
Throws
SQLExceptionif a data source access error occurs
IOExceptionif an IO exception occurs
Reads a WebRowSet object in its XML format from the given Reader object.
Parameters
readerthe java.io.Reader stream from which this WebRowSet object will be populated
Throws
SQLExceptionif a database access error occurs
Releases the current contents of this CachedRowSet object and sends a rowSetChanged event to all registered listeners. Any outstanding updates are discarded and the rowset contains no rows after this method is called. There are no interactions with the underlying data source, and any rowset content, metadata, and content updates should be non-recoverable.

This CachedRowSet object should lock until its contents and associated updates are fully cleared, thus preventing 'dirty' reads by other components that hold a reference to this RowSet object. In addition, the contents cannot be released until all all components reading this CachedRowSet object have completed their reads. This CachedRowSet object should be returned to normal behavior after firing the rowSetChanged event.

The metadata, including JDBC properties and Synchronization SPI properties, are maintained for future use. It is important that properties such as the command property be relevant to the originating data source from which this CachedRowSet object was originally established.

This method empties a rowset, as opposed to the close method, which marks the entire rowset as recoverable to allow the garbage collector the rowset's Java VM resources.

Throws
SQLExceptionif an error occurs flushing the contents of this CachedRowSet object
Restores this CachedRowSet object to its original value, that is, its value before the last set of changes. If there have been no changes to the rowset or only one set of changes, the original value is the value with which this CachedRowSet object was populated; otherwise, the original value is the value it had immediately before its current value.

When this method is called, a CachedRowSet implementation must ensure that all updates, inserts, and deletes to the current rowset instance are replaced by the previous values. In addition, the cursor should be reset to the first row and a rowSetChanged event should be fired to notify all registered listeners.

Throws
SQLExceptionif an error occurs rolling back the current value of this CachedRowSet object to its previous value
Each CachedRowSet object's SyncProvider contains a Connection object from the original ResultSet or JDBC properties passed to it.

Undoes all changes made in the current transaction. This method should be used only when auto-commit mode has been disabled.

Throws
SQLExceptionif a database access error occurs or this Connection object within this CachedRowSet is in auto-commit mode.
Each CachedRowSet object's SyncProvider contains a Connection object from the original ResultSet or JDBC properties passed to it.

Undoes all changes made in the current transaction back to the last Savepoint transaction marker. This method should be used only when auto-commit mode has been disabled.

Parameters
sA Savepoint transaction marker
Throws
SQLExceptionif a database access error occurs or this Connection object within this CachedRowSet is in auto-commit mode.
Notifies registered listeners that a RowSet object in the given RowSetEvent object has populated a number of additional rows. The numRows parameter ensures that this event will only be fired every numRow.

The source of the event can be retrieved with the method event.getSource.

Parameters
eventa RowSetEvent object that contains the RowSet object that is the source of the events
numRowswhen populating, the number of rows interval on which the CachedRowSet populated should fire; the default value is zero; cannot be less than fetchSize or zero
Sets this CachedRowSet object's keyCols field with the given array of column numbers, which forms a key for uniquely identifying a row in this CachedRowSet object.

If a CachedRowSet object becomes part of a JoinRowSet object, the keys defined by this method and the resulting constraints are maintained if the columns designated as key columns also become match columns.

Parameters
keysan array of int indicating the columns that form a primary key for this CachedRowSet object; every element in the array must be greater than 0 and less than or equal to the number of columns in this rowset
Throws
SQLExceptionif any of the numbers in the given array are not valid for this rowset
Sets the metadata for this CachedRowSet object with the given RowSetMetaData object. When a RowSetReader object is reading the contents of a rowset, it creates a RowSetMetaData object and initializes it using the methods in the RowSetMetaData implementation. The reference implementation uses the RowSetMetaDataImpl class. When the reader has completed reading the rowset contents, this method is called internally to pass the RowSetMetaData object to the rowset.
Parameters
mda RowSetMetaData object containing metadata about the columns in this CachedRowSet object
Throws
SQLExceptionif invalid metadata is supplied to the rowset
Sets the current row in this CachedRowSet object as the original row.

This method is called internally after the any modified values in the current row have been synchronized with the data source. The current row must be tagged as no longer inserted, deleted or updated.

A call to setOriginalRow is irreversible.

Throws
SQLExceptionif there is no current row or an error is encountered resetting the contents of the original row
Sets the CachedRowSet object's page-size. A CachedRowSet may be configured to populate itself in page-size sized batches of rows. When either populate() or execute() are called, the CachedRowSet fetches an additional page according to the original SQL query used to populate the RowSet.
Parameters
sizethe page-size of the CachedRowSet
Throws
SQLExceptionif an error occurs setting the CachedRowSet page size or if the page size is less than 0.
Sets the property showDeleted to the given boolean value, which determines whether rows marked for deletion appear in the set of current rows. If the value is set to true, deleted rows are immediately visible with the set of current rows. If the value is set to false, the deleted rows are set as invisible with the current set of rows.

Standard rowset implementations may choose to restrict this behavior due to security considerations or to better fit certain deployment scenarios. This is left as implementations defined and does not represent standard behavior.

Parameters
btrue if deleted rows should be shown; false otherwise
Throws
SQLExceptionif a rowset implementation is unable to to reset whether deleted rows should be visible
Sets the SyncProvider objec for this CachedRowSet object to the one specified. This method allows the SyncProvider object to be reset.

A CachedRowSet implementation should always be instantiated with an available SyncProvider mechanism, but there are cases where resetting the SyncProvider object is desirable or necessary. For example, an application might want to use the default SyncProvider object for a time and then choose to use a provider that has more recently become available and better fits its needs.

Resetting the SyncProvider object causes the RowSet object to request a new SyncProvider implementation from the SyncFactory. This has the effect of resetting all previous connections and relationships with the originating data source and can potentially drastically change the synchronization behavior of a disconnected rowset.

Parameters
providera String object giving the fully qualified class name of a SyncProvider implementation
Throws
SQLExceptionif an error occurs while attempting to reset the SyncProvider implementation
Sets the identifier for the table from which this CachedRowSet object was derived to the given table name. The writer uses this name to determine which table to use when comparing the values in the data source with the CachedRowSet object's values during a synchronization attempt. The table identifier also indicates where modified values from this CachedRowSet object should be written.

The implementation of this CachedRowSet object may obtain the the name internally from the RowSetMetaDataImpl object.

Parameters
tabNamea String object identifying the table from which this CachedRowSet object was derived; cannot be null but may be an empty string
Throws
SQLExceptionif an error is encountered naming the table or tabName is null
Returns the number of rows in this CachedRowSet object.
Return
number of rows in the rowset
Converts this CachedRowSet object to a Collection object that contains all of this CachedRowSet object's data. Implementations have some latitude in how they can represent this Collection object because of the abstract nature of the Collection framework. Each row must be fully represented in either a general purpose Collection implementation or a specialized Collection implementation, such as a TreeMap object or a Vector object. An SQL NULL column value must be represented as a null in the Java programming language.

The standard reference implementation for the CachedRowSet interface uses a TreeMap object for the rowset, with the values in each row being contained in Vector objects. It is expected that most implementations will do the same.

The TreeMap type of collection guarantees that the map will be in ascending key order, sorted according to the natural order for the key's class. Each key references a Vector object that corresponds to one row of a RowSet object. Therefore, the size of each Vector object must be exactly equal to the number of columns in the RowSet object. The key used by the TreeMap collection is determined by the implementation, which may choose to leverage a set key that is available within the internal RowSet tabular structure by virtue of a key already set either on the RowSet object itself or on the underlying SQL data.

Return
a Collection object that contains the values in each row in this CachedRowSet object
Throws
SQLExceptionif an error occurs generating the collection
Converts the designated column in this CachedRowSet object to a Collection object. Implementations have some latitude in how they can represent this Collection object because of the abstract nature of the Collection framework. Each column value should be fully represented in either a general purpose Collection implementation or a specialized Collection implementation, such as a Vector object. An SQL NULL column value must be represented as a null in the Java programming language.

The standard reference implementation uses a Vector object to contain the column values, and it is expected that most implementations will do the same. If a Vector object is used, it size must be exactly equal to the number of rows in this CachedRowSet object.

Parameters
columnan int indicating the column whose values are to be represented in a Collection object
Return
a Collection object that contains the values stored in the specified column of this CachedRowSet object
Throws
SQLExceptionif an error occurs generating the collection or an invalid column id is provided
Converts the designated column in this CachedRowSet object to a Collection object. Implementations have some latitude in how they can represent this Collection object because of the abstract nature of the Collection framework. Each column value should be fully represented in either a general purpose Collection implementation or a specialized Collection implementation, such as a Vector object. An SQL NULL column value must be represented as a null in the Java programming language.

The standard reference implementation uses a Vector object to contain the column values, and it is expected that most implementations will do the same. If a Vector object is used, it size must be exactly equal to the number of rows in this CachedRowSet object.

Parameters
columna String object giving the name of the column whose values are to be represented in a collection
Return
a Collection object that contains the values stored in the specified column of this CachedRowSet object
Throws
SQLExceptionif an error occurs generating the collection or an invalid column id is provided
Cancels the deletion of the current row and notifies listeners that a row has changed. After this method is called, the current row is no longer marked for deletion. This method can be called at any time during the lifetime of the rowset.

In addition, multiple cancellations of row deletions can be made by adjusting the position of the cursor using any of the cursor position control methods such as:

  • CachedRowSet.absolute
  • CachedRowSet.first
  • CachedRowSet.last
Throws
SQLExceptionif (1) the current row has not been deleted or (2) the cursor is on the insert row, before the first row, or after the last row
Immediately removes the current row from this CachedRowSet object if the row has been inserted, and also notifies listeners that a row has changed. This method can be called at any time during the lifetime of a rowset and assuming the current row is within the exception limitations (see below), it cancels the row insertion of the current row.

In addition, multiple cancellations of row insertions can be made by adjusting the position of the cursor using any of the cursor position control methods such as:

  • CachedRowSet.absolute
  • CachedRowSet.first
  • CachedRowSet.last
Throws
SQLExceptionif (1) the current row has not been inserted or (2) the cursor is before the first row, after the last row, or on the insert row
Immediately reverses the last update operation if the row has been modified. This method can be called to reverse updates on all columns until all updates in a row have been rolled back to their state just prior to the last synchronization (acceptChanges) or population. This method may also be called while performing updates to the insert row.

undoUpdate

Throws
SQLExceptionif the cursor is before the first row or after the last row in in this CachedRowSet object
Writes the data, properties, and metadata for this WebRowSet object to the given OutputStream object in XML format.
Parameters
oStreamthe java.io.OutputStream stream to write to
Throws
SQLExceptionif a data source access error occurs
IOExceptionif a IO exception occurs
Populates this WebRowSet object with the contents of the given ResultSet object and writes its data, properties, and metadata to the given OutputStream object in XML format.

NOTE: The WebRowSet cursor may be moved to write out the contents to the XML data source. If implemented in this way, the cursor must be returned to its position just prior to the writeXml() call.

Parameters
rsthe ResultSet object with which to populate this WebRowSet object
oStreamthe java.io.OutputStream to write to
Throws
SQLExceptionif a data source access error occurs
IOExceptionif a IO exception occurs
Populates this WebRowSet object with the contents of the given ResultSet object and writes its data, properties, and metadata to the given Writer object in XML format.

NOTE: The WebRowSet cursor may be moved to write out the contents to the XML data source. If implemented in this way, the cursor must be returned to its position just prior to the writeXml() call.

Parameters
rsthe ResultSet object with which to populate this WebRowSet object
writerthe java.io.Writer object to write to.
Throws
SQLExceptionif an error occurs writing out the rowset contents in XML format
Writes the data, properties, and metadata for this WebRowSet object to the given Writer object in XML format.
Parameters
writerthe java.io.Writer stream to write to
Throws
SQLExceptionif an error occurs writing out the rowset contents to XML