87 lines
4.9 KiB
HTML
87 lines
4.9 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="CallableStatement interface" />
|
|
<meta name="abstract" content="Use a CallableStatement object to run SQL stored procedures. The stored procedure being called must already be stored in the database. CallableStatement does not contain the stored procedure, it only calls the stored procedure." />
|
|
<meta name="description" content="Use a CallableStatement object to run SQL stored procedures. The stored procedure being called must already be stored in the database. CallableStatement does not contain the stored procedure, it only calls the stored procedure." />
|
|
<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="jdbccst" />
|
|
<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>CallableStatement interface</title>
|
|
</head>
|
|
<body id="jdbccst"><a name="jdbccst"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">CallableStatement interface</h1>
|
|
<div><p>Use a CallableStatement object to run SQL stored procedures. The
|
|
stored procedure being called must already be stored in the database. CallableStatement
|
|
does not contain the stored procedure, it only calls the stored procedure.</p>
|
|
<div class="section"><p><a href="javadoc/com/ibm/as400/access/AS400JDBCCallableStatement.html#NAVBAR_TOP"> CallableStatement</a> </p>
|
|
<p>A stored procedure
|
|
can return one or more ResultSet objects and can use IN parameters, OUT parameters,
|
|
and INOUT parameters. Use Connection.prepareCall() to create new CallableStatement
|
|
objects.</p>
|
|
<p>The CallableStatement object allows you to submit multiple
|
|
SQL commands as a single group to a database through the use of batch support.
|
|
You may get better performance by using batch support because processing a
|
|
group of operations is usually faster than processing them one at a time.
|
|
For more information about using batch support, see <a href="rzahhjdbcenhancev5r2.htm#rzahhjdbcenhancev5r2__as400jdbcstatementmethods">Enhancements
|
|
to JDBC support</a>.</p>
|
|
<p>CallableStatement allows you to <a href="rzahhjdbcenhancev5r2.htm#rzahhjdbcenhancev5r2__callablestatementmethods">get and set parameters and columns by name</a>, although using the column
|
|
index results in better performance.</p>
|
|
</div>
|
|
<div class="section"><h4 class="sectiontitle">Example: Using CallableStatement</h4><p>The following example
|
|
shows how to use the CallableStatement interface.</p>
|
|
<pre> // Connect to the server.
|
|
Connection c = DriverManager.getConnection("jdbc:as400://mySystem");
|
|
|
|
// Create the CallableStatement
|
|
// object. It precompiles the
|
|
// specified call to a stored
|
|
// procedure. The question marks
|
|
// indicate where input parameters
|
|
// must be set and where output
|
|
// parameters can be retrieved.
|
|
// The first two parameters are
|
|
// input parameters, and the third
|
|
// parameter is an output parameter.
|
|
CallableStatement cs = c.prepareCall("CALL MYLIBRARY.ADD (?, ?, ?)");
|
|
|
|
// Set input parameters.
|
|
cs.setInt (1, 123);
|
|
cs.setInt (2, 234);
|
|
|
|
// Register the type of the output
|
|
// parameter.
|
|
cs.registerOutParameter (3, Types.INTEGER);
|
|
|
|
// Run the stored procedure.
|
|
cs.execute ();
|
|
|
|
// Get the value of the output
|
|
// parameter.
|
|
int sum = cs.getInt (3);
|
|
|
|
// Close the CallableStatement and
|
|
// the Connection.
|
|
cs.close();
|
|
c.close();</pre>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |