< prev index next >

src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java

Print this page
rev 60127 : 8249205: Remove unnecessary trademark symbols


  29 import javax.sql.*;
  30 import javax.naming.*;
  31 import java.io.*;
  32 import java.math.*;
  33 import java.util.*;
  34 
  35 import javax.sql.rowset.spi.*;
  36 
  37 /**
  38  * The interface that all standard implementations of
  39  * <code>CachedRowSet</code> must implement.
  40  * <P>
  41  * The reference implementation of the <code>CachedRowSet</code> interface provided
  42  * by Oracle Corporation is a standard implementation. Developers may use this implementation
  43  * just as it is, they may extend it, or they may choose to write their own implementations
  44  * of this interface.
  45  * <P>
  46  * A <code>CachedRowSet</code> object is a container for rows of data
  47  * that caches its rows in memory, which makes it possible to operate without always being
  48  * connected to its data source. Further, it is a
  49  * JavaBeans&trade; component and is scrollable,
  50  * updatable, and serializable. A <code>CachedRowSet</code> object typically
  51  * contains rows from a result set, but it can also contain rows from any file
  52  * with a tabular format, such as a spread sheet.  The reference implementation
  53  * supports getting data only from a <code>ResultSet</code> object, but
  54  * developers can extend the <code>SyncProvider</code> implementations to provide
  55  * access to other tabular data sources.
  56  * <P>
  57  * An application can modify the data in a <code>CachedRowSet</code> object, and
  58  * those modifications can then be propagated back to the source of the data.
  59  * <P>
  60  * A <code>CachedRowSet</code> object is a <i>disconnected</i> rowset, which means
  61  * that it makes use of a connection to its data source only briefly. It connects to its
  62  * data source while it is reading data to populate itself with rows and again
  63  * while it is propagating changes back to its underlying data source. The rest
  64  * of the time, a <code>CachedRowSet</code> object is disconnected, including
  65  * while its data is being modified. Being disconnected makes a <code>RowSet</code>
  66  * object much leaner and therefore much easier to pass to another component.  For
  67  * example, a disconnected <code>RowSet</code> object can be serialized and passed
  68  * over the wire to a thin client such as a personal digital assistant (PDA).
  69  *


 393  *
 394  * <h2>9.0 Setting Properties</h2>
 395  * All rowsets maintain a set of properties, which will usually be set using
 396  * a tool.  The number and kinds of properties a rowset has will vary,
 397  * depending on what the rowset does and how it gets its data.  For example,
 398  * rowsets that get their data from a <code>ResultSet</code> object need to
 399  * set the properties that are required for making a database connection.
 400  * If a rowset uses the <code>DriverManager</code> facility to make a
 401  * connection, it needs to set a property for the JDBC URL that identifies
 402  * the appropriate driver, and it needs to set the properties that give the
 403  * user name and password.
 404  * If, on the other hand, the rowset uses a <code>DataSource</code> object
 405  * to make the connection, which is the preferred method, it does not need to
 406  * set the property for the JDBC URL.  Instead, it needs to set
 407  * properties for the logical name of the data source, for the user name,
 408  * and for the password.
 409  * <P>
 410  * NOTE:  In order to use a <code>DataSource</code> object for making a
 411  * connection, the <code>DataSource</code> object must have been registered
 412  * with a naming service that uses the Java Naming and Directory
 413  * Interface&trade; (JNDI) API.  This registration
 414  * is usually done by a person acting in the capacity of a system
 415  * administrator.
 416  * <P>
 417  * In order to be able to populate itself with data from a database, a rowset
 418  * needs to set a command property.  This property is a query that is a
 419  * <code>PreparedStatement</code> object, which allows the query to have
 420  * parameter placeholders that are set at run time, as opposed to design time.
 421  * To set these placeholder parameters with values, a rowset provides
 422  * setter methods for setting values of each data type,
 423  * similar to the setter methods provided by the <code>PreparedStatement</code>
 424  * interface.
 425  * <P>
 426  * The following code fragment illustrates how the <code>CachedRowSet</code>
 427  * object <code>crs</code> might have its command property set.  Note that if a
 428  * tool is used to set properties, this is the code that the tool would use.
 429  * <PRE>{@code
 430  *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS " +
 431  *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
 432  * } </PRE>
 433  * <P>




  29 import javax.sql.*;
  30 import javax.naming.*;
  31 import java.io.*;
  32 import java.math.*;
  33 import java.util.*;
  34 
  35 import javax.sql.rowset.spi.*;
  36 
  37 /**
  38  * The interface that all standard implementations of
  39  * <code>CachedRowSet</code> must implement.
  40  * <P>
  41  * The reference implementation of the <code>CachedRowSet</code> interface provided
  42  * by Oracle Corporation is a standard implementation. Developers may use this implementation
  43  * just as it is, they may extend it, or they may choose to write their own implementations
  44  * of this interface.
  45  * <P>
  46  * A <code>CachedRowSet</code> object is a container for rows of data
  47  * that caches its rows in memory, which makes it possible to operate without always being
  48  * connected to its data source. Further, it is a
  49  * JavaBeans component and is scrollable,
  50  * updatable, and serializable. A <code>CachedRowSet</code> object typically
  51  * contains rows from a result set, but it can also contain rows from any file
  52  * with a tabular format, such as a spread sheet.  The reference implementation
  53  * supports getting data only from a <code>ResultSet</code> object, but
  54  * developers can extend the <code>SyncProvider</code> implementations to provide
  55  * access to other tabular data sources.
  56  * <P>
  57  * An application can modify the data in a <code>CachedRowSet</code> object, and
  58  * those modifications can then be propagated back to the source of the data.
  59  * <P>
  60  * A <code>CachedRowSet</code> object is a <i>disconnected</i> rowset, which means
  61  * that it makes use of a connection to its data source only briefly. It connects to its
  62  * data source while it is reading data to populate itself with rows and again
  63  * while it is propagating changes back to its underlying data source. The rest
  64  * of the time, a <code>CachedRowSet</code> object is disconnected, including
  65  * while its data is being modified. Being disconnected makes a <code>RowSet</code>
  66  * object much leaner and therefore much easier to pass to another component.  For
  67  * example, a disconnected <code>RowSet</code> object can be serialized and passed
  68  * over the wire to a thin client such as a personal digital assistant (PDA).
  69  *


 393  *
 394  * <h2>9.0 Setting Properties</h2>
 395  * All rowsets maintain a set of properties, which will usually be set using
 396  * a tool.  The number and kinds of properties a rowset has will vary,
 397  * depending on what the rowset does and how it gets its data.  For example,
 398  * rowsets that get their data from a <code>ResultSet</code> object need to
 399  * set the properties that are required for making a database connection.
 400  * If a rowset uses the <code>DriverManager</code> facility to make a
 401  * connection, it needs to set a property for the JDBC URL that identifies
 402  * the appropriate driver, and it needs to set the properties that give the
 403  * user name and password.
 404  * If, on the other hand, the rowset uses a <code>DataSource</code> object
 405  * to make the connection, which is the preferred method, it does not need to
 406  * set the property for the JDBC URL.  Instead, it needs to set
 407  * properties for the logical name of the data source, for the user name,
 408  * and for the password.
 409  * <P>
 410  * NOTE:  In order to use a <code>DataSource</code> object for making a
 411  * connection, the <code>DataSource</code> object must have been registered
 412  * with a naming service that uses the Java Naming and Directory
 413  * Interface (JNDI) API.  This registration
 414  * is usually done by a person acting in the capacity of a system
 415  * administrator.
 416  * <P>
 417  * In order to be able to populate itself with data from a database, a rowset
 418  * needs to set a command property.  This property is a query that is a
 419  * <code>PreparedStatement</code> object, which allows the query to have
 420  * parameter placeholders that are set at run time, as opposed to design time.
 421  * To set these placeholder parameters with values, a rowset provides
 422  * setter methods for setting values of each data type,
 423  * similar to the setter methods provided by the <code>PreparedStatement</code>
 424  * interface.
 425  * <P>
 426  * The following code fragment illustrates how the <code>CachedRowSet</code>
 427  * object <code>crs</code> might have its command property set.  Note that if a
 428  * tool is used to set properties, this is the code that the tool would use.
 429  * <PRE>{@code
 430  *    crs.setCommand("SELECT FIRST_NAME, LAST_NAME, ADDRESS FROM CUSTOMERS " +
 431  *                   "WHERE CREDIT_LIMIT > ? AND REGION = ?");
 432  * } </PRE>
 433  * <P>


< prev index next >