Servlets using JDBC or SQLj
Enterprise JavaBeans (EJB) using JDBC or SQLj
DB2 UDB provides an implementation of the two standard based Java
programming interface (APIs), Java Database Connectivity (JDBC), and
embedded SQL for Java (SQLj). This section provides an overview of JDBC,
SQLj, and the conversion of existing MySQL Java applications to DB2 UDB.
MySQL has an optional package MySQL Connector/J, which is a type 4 JDBC
driver. The latest Version of MySQL Connector/J implements SUN's JDBC 3.0
API for relational database access.
Java database connectivity (JDBC)
JDBC is a vendor neutral dynamic SQL interface that provides data access for
your application through standardized Java methods. JDBC drivers provide the
mechanics to the JDBC API to allow Java applications to access databases.
Currently JDBC API is in its third revision, but most of the drivers available in
market comply to JDBC1.2 or JDBC2.0 specification. IBM DB2 V8.1 supports
JDBC2.1 and some methods support JDBC3.0 forms.
A JDBC application can establish a connection to a data source using the JDBC
DriverManager interface. In the following sections we discuss what are the
changes required in Java application code from MySQL to DB2.
IBM JDBC driver for DB2
IBM DB2 UDB provides support for various types of JDBC technology enabled
drivers. The drivers available in DB2 UDB V8.1 are:
DB2 JDBC type 2 driver
The DB2 JDBC type 2 driver, also called the
native API/partly Java driver
,
lets Java applications make JDBC calls that are translated to Java native
methods. The Java applications that use this driver must run a DB2 client,
which is used to communicate the JDBC requests to the DB2 server.
Figure 7 1 shows a call transfer for DB2 JDBC type 2 driver. As shown in
Figure 7 1, this driver can be used only by Java applications. This driver is
implemented using the DB2 CLI interface to communicate with DB2 UDB
servers.
For using DB2 JDBC type 2 driver you need following properties:
drivername= COM.ibm.db2.jdbc.app.DB2Driver
URL= java:db2:dbname
The user ID and password are implicitly picked from the DB2 client setup.
Chapter 7. Application porting
189
footer
Our partners:
PHP: Hypertext Preprocessor Cheap Web Hosting
JSP Web Hosting
Ontario Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Java Hosting
Cheapest Hosting
Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved