DB2 Connect Quick Beginnings for Linux**

Running Java Programs

You can develop Java programs to access DB2 databases with the appropriate Java Development Kit (JDK) on Linux platforms. 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 Connect Personal Edition. 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 Application Development Client 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 refer to theApplication 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 IBM version of the Java Development Kit (JDK) on your development machine. For your DB2 Connect Personal Edition for Linux product, you require the Java Development Kit (JDK) 1.1.8, or later.

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 the Application Development Client.

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.

To run Java programs, the following environment variables are automatically updated when you install DB2 Connect Personal Edition:

In order to build and run SQLJ programs, the CLASSPATH environment variable must be updated to include the following files:

Java Applications

Start your application from the 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 client 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 enter the following command in the command line processor:

   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 ]