IBM Books

Installation and Configuration Supplement


Running Java Programs

You can develop Java programs to access DB2 databases with the appropriate Java Development Kit (JDK) on AIX, HP-UX, Linux, OS/2, Silicon Graphics IRIX, Solaris, or Windows 32-bit operating systems. The JDK includes Java Database Connectivity (JDBC), a dynamic SQL API for Java.

For DB2 JDBC support, you must include the DB2 Java Enablement component when you install the DB2 client. With DB2 JDBC support you can build and run JDBC applications and applets. These contain dynamic SQL only, and use a Java call interface to pass SQL statements to DB2.

The DB2 Software Developer's Kit (DB2 SDK) provides support for Java embedded SQL (SQLJ). With DB2 SQLJ support and DB2 JDBC support you can build and run SQLJ applications and applets. These contain static SQL and use embedded SQL statements that are bound to the DB2 database.

Java can also be used on the server to create JDBC and SQLJ stored procedures and user-defined functions (UDFs).

Building and running different types of Java programs requires support from different components of DB2:

For detailed information on building and running JDBC and SQLJ programs see Application Building Guide. For more information on DB2 programming in Java, refer to the Application Development Guide. This covers creating and running JDBC and SQLJ applications, applets, stored procedures and UDFs.

For the latest, updated DB2 Java information, visit the Web Page at: http://www.software.ibm.com/data/db2/java

Configuring the Environment

To build and run DB2 Java programs, you need to install and configure the appropriate version of the Java Development Kit (JDK) on your development machine:

AIX:
The Java Development Kit (JDK) Version 1.1.2 for AIX from IBM.

HP-UX:
The HP-UX Developer's Kit for Java Release 1.1.3 or later from Hewlett-Packard.

Linux:
The Java Development Kit (JDK) 1.1.7, Version 1a or later for Linux from the Blackdown Organization.

OS/2:
The Java Development Kit (JDK) Version 1.1.4 for OS/2 from IBM.

Silicon Graphics IRIX:
The Java Development Environment 3.1 (Sun JDK 1.1.5) and the Java Execution Environment 3.1 (Sun JRE 1.1.5) from Silicon Graphics, Inc.

Solaris:
The Java Development Kit (JDK) Version 1.1.4 for Solaris, and the Solaris Native Thread pack, from Sun Microsystems.

Windows 32-bit operating systems
The Java Development Kit (JDK) Version 1.1 for Win32 from Sun Microsystems.

For information on installing and configuring any of the above JDKs, please refer to: http://www.software.ibm.com/data/db2/java

For all supported platforms, you must also install and configure a DB2 client with the DB2 Java Enablement component. To bind SQLJ programs to a database, you must install and configure a DB2 Administrative Client with the DB2 Java Enablement component.

To run DB2 Java stored procedures or UDFs, you also need to update the DB2 database manager configuration to include the path where the JDK version 1.1 is installed on your development machine. You can do this by entering the following on the command line:

   db2 update dbm cfg using JDK11_PATH /home/smith/jdk11

where /home/smith/jdk11 is the path where the JDK version 1.1 is installed.

You can check the DB2 database manager configuration to verify the correct value for the JDK11_PATH field by entering the following command:

   db2 get dbm cfg

You may want to pipe the output to a file for easier viewing. The JDK11_PATH field appears near the beginning of the output. For more information on these commands, refer to the Command Reference.



Figure hint not displayed.

On Solaris, some Java Virtual Machine implementations do not work well in programs that run in a "setuid" environment. The shared library that contains the Java interpreter, libjava.so, may fail to load. As a workaround, you can create symbolic links for all needed JVM shared libraries in /usr/lib, with a command similar to the following (depending on where Java is installed on your machine):
   ln -s /opt/jdk1.1.3/lib/sparc/native_threads/*.so /usr/lib

For more information on this and other workarounds available, please visit:

   http://www.software.ibm.com/data/db2/java/v5/faq.html

To run Java programs, the following environment variables are automatically updated during DB2 installation on OS/2 and the Windows Operating System, and during instance creation on UNIX platforms.

On UNIX platforms:

On Windows and OS/2 platforms:

In order to build and run SQLJ programs, CLASSPATH is also automatically updated to include these files:

On UNIX platforms:

On Windows and OS/2 platforms:

Java Applications

Start your application from the desktop or command line by running the Java interpreter on the executable program with this command:

   java prog_name

where prog_name is the name of the program.

The DB2 JDBC driver handles the JDBC API calls from your application and uses the DB2 CAE to communicate the requests to the server and receive the results.

Figure hint not displayed.

An SQLJ application must be bound to the database before it is run.

Java Applets

Because Java applets are delivered over the web, a web server must be installed on your DB2 machine (server or client).

To run your applet, make sure your .html file is properly configured. Start the JDBC applet server on the TCP/IP port specified in the .html file. For example, if you specified:

   param name=port value='6789'

then you would enter:

   db2jstrt 6789

You must ensure that your working directory is accessible to your web browser. If it is not, copy your applet's .class and .html files into a directory that is accessible. For SQLJ applets, you must also copy the profile .class and .ser files as well.

Copy the sqllib/java/db2java.zip file into the same directory as these other files. For SQLJ applets, also copy the sqllib/java/runtime.zip file into this directory. Then on your client machine start your web browser (which supports JDK 1.1) and load the .html file.

When your applet calls the JDBC API to connect to DB2, the JDBC driver establishes separate communications with the DB2 database through the JDBC applet server residing on the DB2 server.

Figure hint not displayed.

An SQLJ applet must be bound to the database before it is run.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]