EasyManuals Logo

IBM DB2 User Manual

IBM DB2
585 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #119 background imageLoading...
Page #119 background image
Notes to Figure 27 on page 101:
Note Description
1 These statements import the java.sql package, which contains the JDBC core
API, and the sqlj.runtime package, which contains the SQLJ API. For
information on other packages or classes that you might need to access, see
Java packages for SQLJ support.
2 String variables hvmgr and hvdeptno are host identifiers, which are equivalent
to DB2 host variables. See Variables in SQLJ applications for more
information.
3a, 3b, 3c,
and 3d
These statements demonstrate how to connect to a data source using one of the
three available techniques. See Connecting to a data source using SQLJ for
more details.
Step 3b (loading the JDBC driver) is not necessary if you use JDBC 4.0.
4a , 4b, 4c,
and 4d
These statements demonstrate how to execute SQL statements in SQLJ.
Statement 4a demonstrates the SQLJ equivalent of declaring an SQL cursor.
Statements 4b and 4c show one way of doing the SQLJ equivalent of executing
SQL FETCHes. Statement 4d shows how to do the SQLJ equivalent of
performing an SQL UPDATE. For more information, see SQL statements in an
SQLJ application.
5 This try/catch block demonstrates the use of the SQLException class for SQL
error handling. For more information on handling SQL errors, see Handling
SQL errors in an SQLJ application. For more information on handling SQL
warnings, see Handling SQL warnings in an SQLJ application.
6 This is an example of a comment. For rules on including comments in SQLJ
programs, see Comments in an SQLJ application.
7 This statement closes the connection to the data source. See Closing the
connection to the data source in an SQLJ application.
Related concepts
“Java packages for SQLJ support” on page 110
“Variables in SQLJ applications” on page 110
“SQL statement execution in SQLJ applications” on page 112
“Comments in an SQLJ application” on page 112
Related tasks
“Connecting to a data source using SQLJ”
“Handling SQL errors in an SQLJ application” on page 154
“Handling SQL warnings in an SQLJ application” on page 155
“Closing the connection to a data source in an SQLJ application” on page 156
Connecting to a data source using SQLJ
In an SQLJ application, as in any other DB2 application, you must be connected to
a data source before you can execute SQL statements.
You can use one of six techniques to connect to a data source in an SQLJ program.
Two use the JDBC DriverManager interface, two use the JDBC DataSource interface,
one uses a previously created connection context, and one uses the default
connection.
Related concepts
“How JDBC applications connect to a data source” on page 9
“Example of a simple SQLJ application” on page 101
“SQLJ and JDBC in the same application” on page 139
Chapter 4. SQLJ application programming 103

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the IBM DB2 and is the answer not in the manual?

IBM DB2 Specifications

General IconGeneral
DeveloperIBM
Initial Release1983
LicenseProprietary
Written inC, C++
CategoryDatabase Management System (RDBMS)
Operating SystemLinux, Windows
Programming LanguagesC, C++
Data ModelsRelational
EditionsCommunity, Standard, Advanced
Key Featureshigh availability, scalability