110 lines
8.2 KiB
HTML
110 lines
8.2 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="concept" />
|
||
|
<meta name="DC.Title" content="Use DB2CachedRowSet" />
|
||
|
<meta name="abstract" content="Because the DB2CachedRowSet object can be disconnected and serialized, it is useful in environments where it is not always practical to run a full JDBC driver (for example, on Personal Digital Assistants (PDAs) and Java-enabled cell phones)." />
|
||
|
<meta name="description" content="Because the DB2CachedRowSet object can be disconnected and serialized, it is useful in environments where it is not always practical to run a full JDBC driver (for example, on Personal Digital Assistants (PDAs) and Java-enabled cell phones)." />
|
||
|
<meta name="DC.Relation" scheme="URI" content="db2cache.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="crdb2cac.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="accdb2ca.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="chgdb2ca.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="db2cafea.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="db2cause" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Use DB2CachedRowSet</title>
|
||
|
</head>
|
||
|
<body id="db2cause"><a name="db2cause"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Use DB2CachedRowSet</h1>
|
||
|
<div><p>Because the DB2CachedRowSet object can be disconnected and serialized,
|
||
|
it is useful in environments where it is not always practical to run a full
|
||
|
JDBC driver (for example, on Personal Digital Assistants (PDAs) and Java-enabled
|
||
|
cell phones).</p>
|
||
|
<p>Since the DB2CachedRowSet object is contained in memory and its data is
|
||
|
always known, it can serve as a highly optimized form of a scrollable ResultSet
|
||
|
for applications. Whereas DB2ResultSets that are scrollable typically pay
|
||
|
a performance penalty because their random movements interfere with the JDBC
|
||
|
driver's ability to cache rows of data, RowSets do not have this issue.</p>
|
||
|
<p>Two methods are provided on DB2CachedRowSet that create new RowSets:</p>
|
||
|
<ul><li>The createCopy method creates a new RowSet that is identical to the copied
|
||
|
one.</li>
|
||
|
<li>The createShared method creates a new RowSet that shares the same underlying
|
||
|
data as the original.</li>
|
||
|
</ul>
|
||
|
<p>You can use the createCopy method to hand out common ResultSets to clients.
|
||
|
If the table data is not changing, creating a copy of a RowSet and passing
|
||
|
it to each client is more efficient than running a query against the database
|
||
|
each time.</p>
|
||
|
<p>You can use the createShared method to improve your database's performance
|
||
|
by allowing several people to use the same data. For example, assume that
|
||
|
you have a Web site that shows the top twenty best-selling products on your
|
||
|
home page when a customer connects. You want the information on your main
|
||
|
page to be updated regularly, but running the query to get the most frequently
|
||
|
purchased items every time a customer visits your main page is not practical.
|
||
|
Using the createShared method, you can effectively create "cursors" for each
|
||
|
customer without having to either process the query again or store an enormous
|
||
|
amount of information in memory. When appropriate, the query to find the most
|
||
|
frequently purchased products can be run again. The new data can populate
|
||
|
the RowSet that is used to create the shared cursors and the servlets can
|
||
|
use them.</p>
|
||
|
<p>DB2CachedRowSets provide a delayed processing feature. This feature allows
|
||
|
multiple query requests to be grouped together and processed against the database
|
||
|
as a single request. This is an example of <a href="crdb2cac.htm">using
|
||
|
DB2CachedRowSets</a> to eliminate some of the computational stress that
|
||
|
the database would otherwise be under.</p>
|
||
|
<p>Because the RowSet must keep careful track of any changes that happen to
|
||
|
it so that they are reflected back to the database, there is support for functions
|
||
|
that undo changes or allow you to see all changes have been made. For example,
|
||
|
there is a showDeleted method that can be used to tell the RowSet to let you
|
||
|
fetch deleted rows. There are also cancelRowInsert and cancelRowDelete methods
|
||
|
to undo row insertions and deletions, respectfully, after they have been made.</p>
|
||
|
<p>The DB2CachedRowSet object offers better interoperability with other Java™ APIs
|
||
|
because of its event handling support and its toCollection methods that allow
|
||
|
a RowSet or a portion of it to be converted into a Java collection.</p>
|
||
|
<p>The event handling support of DB2CachedRowSet can be used in graphical
|
||
|
user interface (GUI) applications to control displays, for logging information
|
||
|
about changes to the RowSet as they are made, or to find information about
|
||
|
changes to sources other than RowSets. See <a href="db2rowev.htm">Example:
|
||
|
DB2JdbcRowSet events</a> for details.</p>
|
||
|
<p>For specific details on working with DB2CachedRowSets, see the following
|
||
|
topics:</p>
|
||
|
<ul><li><a href="crdb2cac.htm">Create and populate a DB2CachedRowSet</a></li>
|
||
|
<li><a href="accdb2ca.htm">Access DB2CachedRowSet data and cursor manipulation</a></li>
|
||
|
<li><a href="chgdb2ca.htm">Change DB2CachedRowSet data and reflect changes
|
||
|
back to the data source</a></li>
|
||
|
<li><a href="db2cafea.htm">Other DB2CachedRowSet features</a></li>
|
||
|
</ul>
|
||
|
<p>For information on the event model and event handling, see <a href="db2jdbcr.htm">DB2JdbcRowSet</a> as
|
||
|
this support works identically for both types of RowSets. </p>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="db2cache.htm" title="The DB2CachedRowSet object is a disconnected RowSet, meaning that it can be used without being connected to the database. Its implementation adheres closely to the description of a CachedRowSet. The DB2CachedRowSet is a container for rows of data from a ResultSet. The DB2CachedRowSet holds all its own data so it does not need to maintain a connection to the database other than explicitly while reading or writing data to the database.">DB2CachedRowSet</a></div>
|
||
|
</div>
|
||
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
||
|
<div><a href="db2cafea.htm" title="In addition to working like a ResultSet as several examples have shown, the DB2CachedRowSet class has some additional functionality that makes it more flexible to use. Methods are provided for turning either the entire Java Database Connectivity (JDBC) RowSet or just a portion of it into a Java collection. Moreover, because of their disconnected nature, DB2CachedRowSets do not have a strict one-to-one relationship with ResultSets.">Other DB2CachedRowSet features</a></div>
|
||
|
</div>
|
||
|
<div class="relref"><strong>Related reference</strong><br />
|
||
|
<div><a href="crdb2cac.htm" title="There are several ways to place data into a DB2CachedRowSet.">Create and populate a DB2CachedRowSet</a></div>
|
||
|
<div><a href="accdb2ca.htm" title="This topic provides information about accessing DB2CachedRowSet data and various cursor manipulation functions.">Access DB2CachedRowSet data and cursor manipulation</a></div>
|
||
|
<div><a href="chgdb2ca.htm" title="This topic provides information about making changes to rows in a DB2CachedRowSet and then updating the underlying database.">Change DB2CachedRowSet data and reflect changes back to the data source</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|