IBM Books

Application Building Guide


Setting the Environment

AIX

To build Java applications on AIX with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. The Java Development Kit (JDK) Version 1.1.2 or later for AIX from IBM (refer to http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for AIX clients and servers. For previous versions of DB2 for AIX, this support has been provided by the DB2 Client Application Enabler for AIX, Version 2.1.2 or later.

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

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

where /home/db2inst/jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.

To run JDBC and SQLJ programs on AIX with DB2 JDBC support, commands to update the AIX Java environment are included in the database manager files db2profile and db2cshrc. When a DB2 instance is created, .profile and/or .cshrc are modified so that:

  1. LD_LIBRARY_PATH includes sqllib/lib.

  2. CLASSPATH includes:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/runtime.zip

HP-UX

To build Java applications on HP-UX with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. The HP-UX Developer's Kit for Java Release 1.1.3 or later from Hewlett-Packard (refer to http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for HP-UX clients and servers. For previous versions of DB2 for HP-UX, this support has been provided by the DB2 Client Application Enabler for HP-UX, Version 2.1.2 or later.

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

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

where /home/db2inst/jdk11 is the path where the JDK is installed.
Note:Java Stored Procedures and UDFs are only available on HP-UX Version 11

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

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.

To run JDBC and SQLJ programs on HP-UX with DB2 JDBC support, commands to update the HP-UX Java environment are included in the database manager files db2profile and db2cshrc. When a DB2 instance is created, .profile and/or .cshrc are modified so that:

  1. THREADS_FLAG is set to "native".

  2. CLASSPATH includes:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/runtime.zip

Linux

To build Java applications on Linux with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. Java Development Kit (JDK) 1.1.7, Version 1a or later for Linux from the Blackdown Organization. (see http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for Linux clients and servers. For DB2 for Linux Version 5.2 (beta), this support has been provided with the DB2 Client Application Enabler for Linux, Version 5.2.

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

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

where /home/db2inst/jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.
Note:On Linux, the Java Virtual Machine implementation does 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 a symbolic link to the JVM shared library in /usr/lib, with a command similar to the following (depending on where Java is installed on your machine):
   ln -s /usr/local/jdk117_v1a/lib/i686/native_threads/libjava.so /usr/lib
For more information on this and other workarounds available, please visit:
   
   

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

To run JDBC and SQLJ programs on Linux with DB2 JDBC support, commands to update your Linux Java environment are included in the database manager files db2profile and db2cshrc. When a DB2 instance is created, .bashrc, .profile, and/or .cshrc are modified so that:

  1. THREADS_FLAG is set to "native".

  2. CLASSPATH includes:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/runtime.zip

OS/2

To build Java applications on OS/2 with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. The Java Development Kit (JDK) Version 1.1.4 for OS/2 from IBM (refer to http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for OS/2 clients and servers. For previous versions of DB2 for OS/2, this support has been provided by the DB2 Client Application Enabler for OS/2, Version 2.1.2 or later.

The JDK must be installed in an HPFS drive to allow long filenames with extensions greater than three characters, such as .java. Your Java working directory must also be on an HPFS drive. If you will be running Java stored procedures or UDFs on an OS/2 server, DB2 must be installed on an HPFS drive on the server in order to allow the stored procedure or UDF .class files to be placed in the %DB2PATH%\function directory.

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

   db2 update dbm cfg using JDK11_PATH c:\jdk11

where c:\jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.

To run JDBC and SQLJ programs on OS/2 with DB2 JDBC support, the CLASSPATH environment variable is automatically updated when DB2 is installed to include:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   %DB2PATH%\java\sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   %DB2PATH%\java\runtime.zip

Silicon Graphics IRIX

To build Java applications on Silicon Graphics IRIX with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. 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. (refer to http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for Silicon Graphics IRIX clients. For previous DB2 for Silicon Graphics IRIX clients, this support has been provided by the DB2 Client Application Enabler for Silicon Graphics IRIX, Version 2.1.2 or later.

DB2 for Silicon Graphics IRIX is client-only. To run DB2 applications and applets, and to build DB2 embedded SQL applications and applets, you need to access a DB2 database on a server machine from your client machine. The server machine will be running a different operating system. See DB2 for UNIX Quick Beginnings for information on configuring client-to-server communication.

Also, since you will be accessing a database on the server from a remote client that is running on a different operating system, you need to bind the database utilities, including the DB2 CLI, to the database. See "Binding" for more information.

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

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

where /home/db2inst/jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.

To run JDBC and SQLJ programs on Silicon Graphics IRIX with DB2 JDBC support, commands to update the Silicon Graphics IRIX Java environment are included in the database manager files db2profile and db2cshrc. When a DB2 instance is created, .profile and/or .cshrc are modified so that CLASSPATH includes:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/runtime.zip
Note:On Silicon Graphics IRIX, the connection context close() method may cause a trap. As a work-around, leave the connection context to be closed automatically during garbage collection.

Solaris

To build Java applications on Solaris with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. The Java Development Kit (JDK) Version 1.1.4 or later for Solaris, and the Solaris Native Thread pack, from Sun Microsystems (refer to http://www.software.ibm.com/data/db2/java ).

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for Solaris clients and servers. For previous versions of DB2 for Solaris, this support has been provided by the DB2 Client Application Enabler for Solaris, Version 2.1.2 or later.

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

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

where /home/db2inst/jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.
Note: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 (and depending on where Java is installed on your machine):
   ln -s /opt/jdk1.1.4/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/faq.html

To run JDBC and SQLJ programs on Solaris with DB2 JDBC support, commands to update the Solaris Java environment are included in the database manager files db2profile and db2cshrc. When a DB2 instance is created, .profile and/or .cshrc are modified so that:

  1. THREADS_FLAG is set to "native".

  2. CLASSPATH includes:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   sqllib/java/runtime.zip

Windows 32-bit Operating Systems

To build Java applications on a Windows 32-bit platform with DB2 JDBC support, you need to install and configure the following on your development machine:

  1. One of the following:

  2. DB2 Java Enablement, provided on DB2 Universal Database Version 6.1 for Windows 32-bit operating systems clients and servers. For previous versions of DB2 for Windows, this support has been provided by the DB2 Client Application Enabler for Windows NT and Windows 95, Version 2.1.2 or later.

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

   db2 update dbm cfg using JDK11_PATH c:\jdk11

where c:\jdk11 is the path where the JDK 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 on the server:

   db2 get dbm cfg

You may want to redirect 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, see the Command Reference.

To run JDBC and SQLJ programs on a supported Windows platform with DB2 JDBC support, CLASSPATH is automatically updated when DB2 is installed to include:

To build SQLJ programs, CLASSPATH is also updated to include the file:

   
   %DB2PATH%\java\sqlj.zip

To run SQLJ programs, CLASSPATH is also updated to include the file:

   
   %DB2PATH%\java\runtime.zip

To specify which Java Development Kit to use for DB2 SQLJ, DB2 installs the environment variable DB2JVIEW on Windows 32-bit operating systems. It applies to all DB2 SQLJ commands (db2profc, db2profp, profdb, profp and sqlj).

If the default setting of "DB2JVIEW=0" is used, or DB2JVIEW is not set, the Sun JDK will be used; that is, if you call "profp", it will run as "java sqlj.runtime.profile.util.ProfilePrinter". If "DB2JVIEW=1", the Microsoft SDK for Java will be used; that is, if you call "profp", it will run as "jview sqlj.runtime.profile.util.ProfilePrinter".


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

[ DB2 List of Books | Search the DB2 Books ]