Java Reference
In-Depth Information
Using the Java API
The Java API is a good tool to look up information about a class with which
you may be unfamiliar or to check the syntax of commands and methods you
wish to use in your programs. While connected to the Internet, start a browser,
type http://java.sun.com/j2se/5.0/docs/api/index.html in the Address
text box, and then press the ENTER key to view the Java API Specification on the
Sun Web site. (Or, if you downloaded the documentation from the CD-ROM
that accompanies this topic, navigate to the installed version of the Java SDK
documentation on your system. Open the index.html file in the docs\api folder.)
With the Java API Specification open in the browser window, perform the
following steps.
1. Use the scroll bar in the lower-left frame, if necessary, to scroll to the
PreparedStatement link. Click the PreparedStatement link.
2. When the Interface PreparedStatement page is displayed, read the paragraph
that describes the PreparedStatement interface, as shown in Figure 11-79.
3. Scroll down to the Method Summary table. Click the link for the
executeQuery() method. When the method definition is displayed, drag
through the definition and the executeUpdate() method definition to select
them. Click File on the browser's menu bar and then click Print on the File
menu to print a copy of the definitions. When the Print dialog box is dis-
played, click Print selection and then click the Print button in the Print
dialog box.
4. Scroll to the top of the Interface PreparedStatement page. Under the line, All
Superinterfaces, click the Statement link.
5. When the Interface Statement page is displayed, read the paragraph that
describes the Statement interface. As you did in Step 3 above for a
PreparedStatement, display, select, and print the executeQuery() method
and the executeUpdate() method definitions for a Statement.
6. Compare the PreparedStatement executeUpdate() and executeQuery()
method definitions with those for a Statement and answer the following
questions:
a) How do the corresponding methods for a PreparedStatement and a
Statement differ?
b) Disregarding dynamic versus static, can both objects process the same
SQL statements?
c) The text indicated that an update or delete might affect more than a single
record. Do either or both of these objects tell you the number of records
updated or deleted by an SQL statement? If so, describe how you would
obtain that information.
Search WWH ::




Custom Search