ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/vjdbcdoc.htm

77 lines
4.4 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="reference" />
<meta name="DC.Title" content="SQLStatementDocument class" />
<meta name="abstract" content="" />
<meta name="description" content="" />
<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="vjdbcdoc" />
<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>SQLStatementDocument class</title>
</head>
<body id="vjdbcdoc"><a name="vjdbcdoc"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">SQLStatementDocument class</h1>
<div><p></p>
<div class="section"><p>The <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#NAVBAR_TOP"> SQLStatementDocument</a> class is an implementation of the Java™ Foundation
Classes (JFC) Document interface. It can be used directly with any JFC graphical
text component. Several text components, such as single line fields (JTextField)
and multiple line text areas (JTextArea), are available in JFC. SQLStatementDocument
objects associate the contents of text components with SQLConnection objects.
The Java program
can run the SQL statement contained in the document contents at any time and
then process the results, if any.</p>
</div>
<div class="section"><p>To use an SQLStatementDocument, you must set the connection property.
Set this property by using the constructor or the setConnection() method.
The SQLStatementDocument object is then "plugged" into the text component,
typically using the text component's constructor or setDocument() method.
Use <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#EXECUTE()"> execute()</a> at any time to run the SQL statement contained
in the document.</p>
</div>
<div class="section"><p>The following example creates an SQLStatementDocument in a JTextField:</p>
</div>
<div class="section"><div class="p"><pre> // Create an SQLStatementDocument
// object. Assume that "connection"
// is an SQLConnection object that is
// created and initialized elsewhere.
// The text of the document is
// initialized to a generic query.
SQLStatementDocument document = new SQLStatementDocument (connection, "SELECT * FROM QIWS.QCUSTCDT");
// Create a text field to present the
// document.
JTextField textField = new JTextField ();
textField.setDocument (document);
// Add the text field to a frame.
// Assume that "frame" is a JFrame
// created elsewhere.
frame.getContentPane ().add (textField);
// Run the SQL statement that is in
// the text field.
document.execute ();</pre>
</div>
</div>
<div class="section"><p>After the SQL statement is issued, use <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#GETRESULTSET()"> getResultSet()</a>, <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#GETMORERESULTS()"> getMoreResults()</a>, <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#GETUPDATECOUNT()"> getUpdateCount()</a>, or <a href="javadoc/com/ibm/as400/vaccess/SQLStatementDocument.html#GETWARNINGS()"> getWarnings()</a> to retrieve the results.</p>
</div>
</div>
</body>
</html>