/*
* @(#)CachedRowSet.java 1.12 06/04/16
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.sql.rowset;
import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.io.*;
import java.math.*;
import java.util.*;
import javax.sql.rowset.spi.*;
/**
* The interface that all standard implementations of
* <code>CachedRowSet</code> must implement.
* <P>
* The reference implementation of the <code>CachedRowSet</code> interface provided
* by Sun Microsystems is a standard implementation. Developers may use this implementation
* just as it is, they may extend it, or they may choose to write their own implementations
* of this interface.
* <P>
* A <code>CachedRowSet</code> object is a container for rows of data
* that caches its rows in memory, which makes it possible to operate without always being
* connected to its data source. Further, it is a
* JavaBeans<sup><font size=-2>TM</font></sup> component and is scrollable,
* updatable, and serializable. A <code>CachedRowSet</code> object typically
* contains rows from a result set, but it can also contain rows from any file
* with a tabular format, such as a spread sheet. The reference implementation
* supports getting data only from a <code>ResultSet</code> object, but
* developers can extend the <code>SyncProvider</code> implementations to provide
* access to other tabular data sources.
* <P>
* An application can modify the data in a <code>CachedRowSet</code> object, and
* those modifications can then be propagated back to the source of the data.
* <P>
* A <code>CachedRowSet</code> object is a <i>disconnected</i> rowset, which means
* that it makes use of a connection to its data source only briefly. It connects to its
* data source while it is reading data to populate itself with rows and again
* while it is propagating changes back to its underlying data source. The rest
* of the time, a <code>CachedRowSet</code> object is disconnected, including
* while its data is being modified. Being disconnected makes a <code>RowSet</code>
* object much leaner and therefore much easier to pass to another component. For
* example, a disconnected <code>RowSet</code> object can be serialized and passed
* over the wire to a thin client such as a personal digital assistant (PDA).
* <P>
*
* <h3>1.0 Creating a <code>CachedRowSet</code> Object</h3>
* The following line of code uses the default constructor for
* <code>CachedRowSet</code>
* supplied in the reference implementation (RI) to create a default
* <code>CachedRowSet</code> object.
* <PRE>
* CachedRowSetImpl crs = new CachedRowSetImpl();
* </PRE>
* This new <code>CachedRowSet</code> object will have its properties set to the
* default properties of a <code>BaseRowSet</code> object, and, in addition, it will
* have an <code>RIOptimisticProvider</code> object as its synchronization provider.
* <code>RIOptimisticProvider</code>, one of two <code>SyncProvider</code>
* implementations included in the RI, is the default provider that the
* <code>SyncFactory</code> singleton will supply when no synchronization
* provider is specified.
* <P>
* A <code>SyncProvider</code> object provides a <code>CachedRowSet</code> object
* with a reader (a <code>RowSetReader</code> object) for reading data from a
* data source to populate itself with data. A reader can be implemented to read
* data from a <code>ResultSet</code> object or from a file with a tabular format.
* A <code>SyncProvider</code> object also provides
* a writer (a <code>RowSetWriter</code> object) for synchronizing any
* modifications to the <code>CachedRowSet</code> object's data made while it was
* disconnected with the data in the underlying data source.
* <P>
* A writer can be implemented to exercise various degrees of care in checking
* for conflicts and in avoiding them.
* (A conflict occurs when a value in the data source has been changed after
* the rowset populated itself with that value.)
* The <code>RIOptimisticProvider</code> implementation assumes there will be
* few or no conflicts and therefore sets no locks. It updates the data source
* with values from the <code>CachedRowSet</code> object only if there are no
* conflicts.
* Other writers can be implemented so that they always write modified data to
* the data source, which can be accomplished either by not checking for conflicts
* or, on the other end of the spectrum, by setting locks sufficient to prevent data
* in the data source from being changed. Still other writer implementations can be
* somewhere in between.
* <P>
* A <code>CachedRowSet</code> object may use any
* <code>SyncProvider</code> implementation that has been registered
* with the <code>SyncFactory</code> singleton. An application
* can find out which <code>SyncProvider</code> implementations have been
* registered by calling the following line of code.
* <PRE>
* java.util.Enumeration providers = SyncFactory.getRegisteredProviders();
* </PRE>
* <P>
=1= |