182 lines
12 KiB
HTML
182 lines
12 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="reference" />
|
|||
|
<meta name="DC.Title" content="Enhanced JDBC functions for i5/OS Version 5 Release 2" />
|
|||
|
<meta name="abstract" content="Several JDBC functions were enhanced for i5/OS Version 5 Release 2." />
|
|||
|
<meta name="description" content="Several JDBC functions were enhanced for i5/OS Version 5 Release 2." />
|
|||
|
<meta name="DC.Relation" scheme="URI" content="jdbc2.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="rzahhjdbcenhancev5r2" />
|
|||
|
<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>Enhanced JDBC functions for i5/OS Version 5 Release 2</title>
|
|||
|
</head>
|
|||
|
<body id="rzahhjdbcenhancev5r2"><a name="rzahhjdbcenhancev5r2"><!-- --></a>
|
|||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|||
|
<h1 class="topictitle1">Enhanced JDBC functions for i5/OS Version 5 Release 2</h1>
|
|||
|
<div><p>Several JDBC functions were enhanced for i5/OS™ Version 5 Release 2.</p>
|
|||
|
<div class="section"><p>Enhanced JDBC functions for i5/OS Version 5 Release 2 include:</p>
|
|||
|
<ul><li> <a href="#rzahhjdbcenhancev5r2__forupdate">Removal of 'FOR UPDATE'
|
|||
|
restriction</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__datatruncation">Change in data truncation</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__callablestatementmethods">Get and modify
|
|||
|
columns and parameters by name</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__autogenerate">Retrieve auto-generated
|
|||
|
keys</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__as400jdbcstatementmethods">Improved
|
|||
|
performance when running SQL insert statements in a batch</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__resultsetgetrow">Enhanced support for
|
|||
|
ResultSet.getRow()</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__mixedcasecolumn">Improved support for
|
|||
|
using mixed cases in column names</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__holdability">Specify holdability for
|
|||
|
Statements, CallableStatements, and PreparedStatements</a></li>
|
|||
|
<li> <a href="#rzahhjdbcenhancev5r2__transactionisolation">Enhanced transaction
|
|||
|
isolation support</a></li>
|
|||
|
</ul>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__forupdate"><a name="rzahhjdbcenhancev5r2__forupdate"><!-- --></a><dl><dt class="dlterm"><strong>Removal of the 'FOR UPDATE' restriction</strong></dt>
|
|||
|
<dd>You no longer need to specify FOR UPDATE on your SELECT statements in
|
|||
|
order to guarantee an updatable cursor. When connecting to V5R1 and later
|
|||
|
versions of i5/OS, IBM<sup>®</sup> Toolbox
|
|||
|
for Java™ honors
|
|||
|
whatever concurrency you pass in when you create statements. The default
|
|||
|
continues to be a read-only cursor if you do not specify a concurrency.</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__datatruncation"><a name="rzahhjdbcenhancev5r2__datatruncation"><!-- --></a><dl><dt class="dlterm"><strong>Data truncation throws exceptions only when truncated character data
|
|||
|
is written to the database</strong></dt>
|
|||
|
<dd>Data truncation rules for IBM Toolbox for Java now are the same as those for the <a href="jdbc.htm#jdbc">IBM Developer Kit for Java JDBC driver</a>. For more information,
|
|||
|
see <a href="jdbcproperties.htm#jdbcproperties__other">IBM Toolbox for Java JDBC
|
|||
|
properties</a>.</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__callablestatementmethods"><a name="rzahhjdbcenhancev5r2__callablestatementmethods"><!-- --></a><dl><dt class="dlterm"><strong>Get and modify columns and parameters by name</strong></dt>
|
|||
|
<dd>New methods allow you to get and update information by column name in <a href="jdbcrs.htm#jdbcrs">ResultSet</a> and to get and set information
|
|||
|
by parameter name in <a href="jdbccst.htm#jdbccst">CallableStatement</a>.
|
|||
|
For example, in ResultSet, where you previously used the following: <pre> ResultSet rs = statement.executeQuery( SELECT * FROM MYCOLLECTION/MYTABLE );
|
|||
|
rs.getString(1);</pre>
|
|||
|
<p>You can now use:</p>
|
|||
|
<pre> ResultSet rs = statement.executeQuery( SELECT * FROM MYCOLLECTION/MYTABLE );
|
|||
|
rs.getString( 'STUDENTS' );</pre>
|
|||
|
<p>Be aware that accessing
|
|||
|
parameters by their index results in better performance than accessing them
|
|||
|
by their name. You can also specify parameter names to set in CallableStatement.
|
|||
|
Where you might have used the following in CallableStatement:</p>
|
|||
|
<pre> CallableStatement cs = connection.prepareCall( CALL MYPGM (?) );
|
|||
|
cs.setString( 1 );</pre>
|
|||
|
<p>You can now use:</p>
|
|||
|
<pre> CallableStatement cs = connection.prepareCall( CALL MYPGM (?) );
|
|||
|
cs.setString( 'PARAM_1' );</pre>
|
|||
|
<p>To use these new methods,
|
|||
|
you need JDBC 3.0 or later and the Java 2 Platform, version 1.4 (either the
|
|||
|
Standard or the Enterprise Edition).</p>
|
|||
|
</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__autogenerate"><a name="rzahhjdbcenhancev5r2__autogenerate"><!-- --></a><dl><dt class="dlterm"><strong>Retrieve auto-generated keys</strong></dt>
|
|||
|
<dd>The getGeneratedKeys() method on <a href="javadoc/com/ibm/as400/access/AS400JDBCStatement.html">AS400JDBCStatement</a> retrieves any auto-generated keys
|
|||
|
created as a result of executing that Statement object. When the Statement
|
|||
|
object does not generate any keys, an empty ResultSet object is returned.
|
|||
|
Currently the server supports returning only one auto-generated key (the
|
|||
|
key for the last inserted row). The following example shows how you might
|
|||
|
insert a value into a table then get the auto-generated key: <pre> Statement s =
|
|||
|
statement.executeQuery("INSERT INTO MYSCHOOL/MYSTUDENTS (FIRSTNAME) VALUES ('JOHN'");
|
|||
|
ResultSet rs = s.getGeneratedKeys();
|
|||
|
// Currently the iSeries server supports returning only one auto-generated
|
|||
|
// key -- the key for the last inserted row.
|
|||
|
rs.next();
|
|||
|
String autoGeneratedKey = rs.getString(1);
|
|||
|
// Use the auto-generated key, for example, as the primary key in another table</pre>
|
|||
|
<p>To
|
|||
|
retrieve auto-generated keys, you need JDBC 3.0 or later, and the Java 2
|
|||
|
Platform, version 1.4 (either the Standard or the Enterprise Edition). Retrieving
|
|||
|
auto-generated keys also requires connecting to a V5R2 or later version of i5/OS.</p>
|
|||
|
</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__as400jdbcstatementmethods"><a name="rzahhjdbcenhancev5r2__as400jdbcstatementmethods"><!-- --></a><dl><dt class="dlterm"><strong>Improved performance when running SQL insert statements in a batch</strong></dt>
|
|||
|
<dd>Performance of running SQL insert statements in a batch has been improved.
|
|||
|
Run SQL statements in a batch by using the different addBatch() methods available
|
|||
|
in <a href="javadoc/com/ibm/as400/access/AS400JDBCStatement.html">AS400JDBCStatement</a>, <a href="javadoc/com/ibm/as400/access/AS400JDBCPreparedStatement.html">AS400JDBCPreparedStatement</a>, and <a href="javadoc/com/ibm/as400/access/AS400JDBCCallableStatement.html">AS400JDBCCallableStatement</a>. Enhanced batch support affects
|
|||
|
only insert requests. For example, using batch support to process several
|
|||
|
inserts involves only one pass to the server. However, using batch support
|
|||
|
to process an insert, and update, and a delete sends each request individually. <p>To
|
|||
|
use batch support, you need JDBC 2.0 or later and the Java 2
|
|||
|
Platform, version 1.2 (either the Standard or the Enterprise Edition).</p>
|
|||
|
</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__resultsetgetrow"><a name="rzahhjdbcenhancev5r2__resultsetgetrow"><!-- --></a><dl><dt class="dlterm"><strong>Enhanced support for ResultSet.getRow()</strong></dt>
|
|||
|
<dd>Previously, the IBM Toolbox for Java JDBC driver was limited in its support
|
|||
|
for the getRow() method in <a href="jdbcrs.htm#jdbcrs">ResultSet</a>.
|
|||
|
Specifically, using ResultSet.last(), ResultSet.afterLast(), and ResultSet.absolute()
|
|||
|
with a negative value made the current row number not available. The previous
|
|||
|
restrictions are lifted, making this method fully functional.</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__mixedcasecolumn"><a name="rzahhjdbcenhancev5r2__mixedcasecolumn"><!-- --></a><dl><dt class="dlterm"><strong>Using mixed case in column names</strong></dt>
|
|||
|
<dd>IBM Toolbox
|
|||
|
for Java methods
|
|||
|
must match either column names provided by the user or column names provided
|
|||
|
by the application with the names that are on the database table. In either
|
|||
|
case, when a column name is not enclosed in quotes, IBM Toolbox for Java changes the name to uppercase characters
|
|||
|
before matching it against the names on the server. When the column name
|
|||
|
is enclosed in quotes, it must exactly match the name on the server or IBM Toolbox
|
|||
|
for Java throws
|
|||
|
an exception.</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__holdability"><a name="rzahhjdbcenhancev5r2__holdability"><!-- --></a><dl><dt class="dlterm"><strong>Specify holdability in created Statements, CallableStatements, and
|
|||
|
PreparedStatements</strong></dt>
|
|||
|
<dd>New methods in <a href="javadoc/com/ibm/as400/access/AS400JDBCConnection.html">AS400JDBCConnection</a> allow you to specify the holdability
|
|||
|
for Statements, CallableStatements, and PreparedStatements that you create.
|
|||
|
Holdability determines whether cursors are held open or closed when committing
|
|||
|
the transaction. You can now have a statement that has a different holdability
|
|||
|
than its connection object. Also, connection objects can have multiple open
|
|||
|
statement objects, each with a different specified holdability. Calling commit
|
|||
|
causes each statement to be handled according to the holdability specified
|
|||
|
for that statement. <p>Holdability is derived in the following order of precedence:</p>
|
|||
|
<ol><li>Holdability specified on statement creation by using the Connection class
|
|||
|
methods createStatement(), prepareCall(), or prepareStatement().</li>
|
|||
|
<li>Holdability specified by using Connection.setHoldability(int).</li>
|
|||
|
<li>Holdability specified by the IBM Toolbox for Java <a href="jdbcproperties.htm#jdbcproperties__server">JDBC
|
|||
|
cursor hold property</a> (when methods in 1. or 2. are not used)</li>
|
|||
|
</ol>
|
|||
|
<p>To use these methods, you need JDBC 3.0 or later, and the Java 2
|
|||
|
Platform, version 1.4 (either the Standard or the Enterprise Edition). Also,
|
|||
|
servers running a V5R1 or earlier version of i5/OS are able to use only the holdability
|
|||
|
specified by the JDBC cursor hold property.</p>
|
|||
|
</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
<div class="section" id="rzahhjdbcenhancev5r2__transactionisolation"><a name="rzahhjdbcenhancev5r2__transactionisolation"><!-- --></a><dl><dt class="dlterm"><strong>Enhanced transaction isolation support</strong></dt>
|
|||
|
<dd>The IBM Toolbox
|
|||
|
for Java JDBC
|
|||
|
driver now features support for switching to a transaction isolation level
|
|||
|
of *NONE after a connection is made. Before V5R2, the IBM Toolbox for Java JDBC driver threw an exception when
|
|||
|
switching to *NONE after making a connection.</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<div>
|
|||
|
<div class="familylinks">
|
|||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="jdbc2.htm" title="JDBC is an application programming interface (API) included in the Java platform that enables Java programs to connect to a wide range of databases.">JDBC</a></div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</body>
|
|||
|
</html>
|