ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/rsltchar.htm

176 lines
12 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?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="ResultSet characteristics" />
<meta name="abstract" content="This topic discusses ResultSet characteristics such ResultSet types, concurrency, ability to close the ResultSet by committing the connection object, and specification of ResultSet characteristics." />
<meta name="description" content="This topic discusses ResultSet characteristics such ResultSet types, concurrency, ability to close the ResultSet by committing the connection object, and specification of ResultSet characteristics." />
<meta name="DC.Relation" scheme="URI" content="rsltsets.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltcurs.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltdata.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltchng.htm" />
<meta name="DC.Relation" scheme="URI" content="rsltclse.htm" />
<meta name="DC.Relation" scheme="URI" content="resultex.htm" />
<meta name="DC.Relation" scheme="URI" content="sensitive.htm" />
<meta name="DC.Relation" scheme="URI" content="sensitive2.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="rsltchar" />
<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>ResultSet characteristics</title>
</head>
<body id="rsltchar"><a name="rsltchar"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">ResultSet characteristics</h1>
<div><p>This topic discusses ResultSet characteristics such ResultSet types,
concurrency, ability to close the ResultSet by committing the connection object,
and specification of ResultSet characteristics.</p>
<p>By default, all created ResultSets have a type of forward only, a concurrency
of read only, and cursors are held over commit boundaries. An exception to
this is that WebSphere<sup>®</sup> currently
changes the cursor holdability default so that cursors are implicitly closed
when committed. These characteristics are configurable through methods that
are accessible on Statement, PreparedStatement, and CallableStatement objects.</p>
<div class="section"><h4 class="sectiontitle">ResultSet types</h4><p>The ResultSet type specifies the
following about the ResultSet:</p>
<ul><li>Whether the ResultSet is scrollable.</li>
<li>The types of Java™ Database Connectivity (JDBC) ResultSets that are
defined by constants on the ResultSet interface.</li>
</ul>
<p>Definitions of these ResultSet types are as follows:</p>
<dl><dt class="dlterm"><strong>TYPE_FORWARD_ONLY</strong></dt>
<dd>A cursor that can only be used to process from the beginning of a ResultSet
to the end of it. This is the default type.</dd>
</dl>
<dl><dt class="dlterm"><strong>TYPE_SCROLL_INSENSITIVE</strong></dt>
<dd>A cursor that can be used to <a href="rsltcurs.htm">scroll in various
ways</a> through a ResultSet. This type of cursor is insensitive to changes
made to the database while it is open. It contains rows that satisfy the query
when the query was processed or when data is fetched.</dd>
</dl>
<dl><dt class="dlterm"><strong>TYPE_SCROLL_SENSITIVE</strong></dt>
<dd>A cursor that can be used to scroll in various ways through a ResultSet.
This type of cursor is sensitive to changes made to the database while it
is open. Changes to the database have a direct impact on the ResultSet data.</dd>
</dl>
<p>JDBC 1.0 ResultSets are always forward only. Scrollable
cursors were added in JDBC 2.0.</p>
<p><strong>Note:</strong> The blocking enabled and
block size connection properties affect the degree of sensitivity of a TYPE_SCROLL_SENSITIVE
cursor. Blocking enhances performance by caching data in the JDBC driver layer
itself.</p>
<p>See <a href="sensitive.htm">Example: Sensitive and insensitive
ResultSets</a> that shows the difference between sensitive and insensitive
ResultSets when rows are inserted into a table.</p>
<p>See <a href="sensitive2.htm">Example:
ResultSet sensitivity</a> that shows how a change can affect a where clause
of an SQL statement based on the sensitivity of the ResultSet.</p>
</div>
<div class="section"><h4 class="sectiontitle">Concurrency</h4><p>Concurrency determines whether the ResultSet
can be updated. The types are again defined by constants in the ResultSet
interface. The available concurrency settings are as follows:</p>
<dl><dt class="dlterm"><strong>CONCUR_READ_ONLY</strong></dt>
<dd>A ResultSet that can only be used for reading data out of the database.
This is the default setting.</dd>
</dl>
<dl><dt class="dlterm"><strong>CONCUR_UPDATEABLE</strong></dt>
<dd>A ResultSet that allows you to make changes to it. These changes can be
placed into the underlying database. See <a href="rsltchng.htm">Change
ResultSets</a> for more information.</dd>
</dl>
<p>JDBC 1.0 ResultSets are always forward only. Updateable
ResultSets were added in JDBC 2.0.</p>
<div class="note"><span class="notetitle">Note:</span> According to the JDBC specification,
the JDBC driver is allowed to change the ResultSet type of the ResultSet concurrency
setting if the values cannot be used together. In such cases, the JDBC driver
places a warning on the Connection object.</div>
<p>There is one situation
where the application specifies a TYPE_SCROLL_INSENSITIVE, CONCUR_UPDATEABLE
ResultSet. Insensitivity is implemented in the database engine by making a
copy of the data. You are then not allowed to make updates through that copy
to the underlying database. If you specify this combination, the driver changes
the sensitivity to TYPE_SCROLL_SENSITIVE and create the warning indicating
that your request has been changed.</p>
</div>
<div class="section"><h4 class="sectiontitle">Holdability</h4><p>The holdability characteristic determines
whether calling commit on the Connection object closes the ResultSet. The
JDBC API for working with the holdability characteristic is new in version
3.0. However, the native JDBC driver has provided a connection property for
several releases that allows you to specify that default for all ResultSets
created under the connection (see <a href="conprop.htm">Connection properties</a> and <a href="dasrprop.htm">DataSource properties</a>). The API support overrides
any setting for the connection property. Values for the holdability characteristic
are defined by ResultSet constants and are as follows:</p>
<dl><dt class="dlterm"><strong>HOLD_CURSOR_OVER_COMMIT</strong></dt>
<dd>All open cursors remain open when the commit clause is called. This is
the native JDBC default value.</dd>
</dl>
<dl><dt class="dlterm"><strong>CLOSE_CURSORS_ON_COMMIT</strong></dt>
<dd>All open cursors are closed when commit clause is called.</dd>
</dl>
<div class="note"><span class="notetitle">Note:</span> Calling rollback on a connection always closes all open
cursors. This is a little known fact, but a common way for databases to handle
cursors.</div>
<p>According to the JDBC specification, the default for cursor
holdability is implementation-defined. Some platforms choose to use CLOSE_CURSORS_ON_COMMIT
as the default. This does not usually become an issue for most applications,
but you must be aware of what the driver you are working with does if you
are working with cursors across commit boundaries. The IBM<sup>®</sup> Toolbox for Java JDBC driver also uses the HOLD_CURSORS_ON_COMMIT
default, but the JDBC driver for UDB for Windows NT<sup>®</sup> has a default of CLOSE_CURSORS_ON_COMMIT.</p>
</div>
<div class="section"><h4 class="sectiontitle">Specify ResultSet characteristics</h4><p>A ResultSet's
characteristics do not change once the ResultSet object has been created.
Therefore, the characteristics have be specified before creating the object.
You can specify these characteristics through overloaded variations of the
createStatement, prepareStatement, and prepareCall methods.</p>
<p>See the
following topics to specify ResultSet characteristics:</p>
<ul><li><a href="statemnt.htm">Specify ResultSet characteristics</a> for
Statements</li>
<li><a href="prepstat.htm">Specify ResultSet characteristics and automatically
generated key support</a> for PreparedStatement</li>
<li><a href="callable.htm">Specify ResultSet characteristics and auto-generated
key support</a> for CallableStatements</li>
</ul>
<div class="note"><span class="notetitle">Note:</span> There are ResultSet methods to obtain the ResultSet type and the
concurrency of the ResultSet, but there is no method to obtain the holdability
of the ResultSet.</div>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="sensitive.htm">Example: Sensitive and insensitive ResultSets</a></strong><br />
The following example shows the difference between sensitive and insensitive ResultSets when rows are inserted into a table.</li>
<li class="ulchildlink"><strong><a href="sensitive2.htm">Example: ResultSet sensitivity</a></strong><br />
The following example shows how a change can affect a where clause of an SQL statement based on the sensitivity of the ResultSet.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rsltsets.htm" title="The ResultSet interface provides access to the results generated by running queries. Conceptually, data of a ResultSet can be thought of as a table with a specific number of columns and a specific number of rows. By default, the table rows are retrieved in sequence. Within a row, column values can be accessed in any order.">ResultSets</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="rsltcurs.htm" title="The iSeries Java Database Connectivity (JDBC) drivers support scrollable ResultSets. With a scrollable ResultSet, you can process rows of data in any order using a number of cursor-positioning methods.">Cursor movement</a></div>
<div><a href="rsltdata.htm" title="The ResultSet object provides several methods for obtaining column data for a row. All are of the form get&lt;Type&gt;, where &lt;Type&gt; is a Java data type. Some examples of these methods include getInt, getLong, getString, getTimestamp, and getBlob. Nearly all of these methods take a single parameter that is either the column index within the ResultSet or the column name.">Retrieve ResultSet data</a></div>
<div><a href="rsltclse.htm" title="To create a ResultSet object, you can use executeQuery methods, or other methods. This article describes options for creating ResultSets.">Create ResultSets</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="rsltchng.htm" title="With the iSeries JDBC drivers, you can change ResultSets by performing several tasks.">Change ResultSets</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="resultex.htm" title="This is an example of how to use the ResultSet interface.">Example: ResultSet interface for IBM Developer Kit for Java</a></div>
</div>
</div>
</body>
</html>