DB2 Version 9.7 for Linux, UNIX, and Windows

Building SQLJ applications

You can use a Java™ makefile or the bldsqlj build file to build SQLJ applications.

The following steps demonstrate how to build and run the TbMod sample SQLJ application. These steps use the build file, bldsqlj (UNIX), or bldsqlj.bat (Windows), which contains commands to build either an SQLJ applet or application.

The build file takes up to six parameters: $1, $2, $3, $4, $5, and $6 on UNIX, and %1, %2, %3, %4, %5, and %6 on Windows. The first parameter specifies the name of your program. The second parameter specifies the user ID for the database instance, the third parameter specifies the password. The fourth parameter specifies the server name. The fifth parameter specifies the port number. And the sixth parameter specifies the database name. For all but the first parameter, program name, default values can be used. See the build file for details about using default parameter values.

  1. Build the application with this command:
       bldsqlj TbMod <userid> <password> <server_name> <port_number> <db_name>
  2. If you are running a Java application on UNIX in a 64-bit DB2 instance but the software development kit for Java is 32-bit, you need to change the DB2 library path before running the application. For example, on AIX®:
    • If using bash or Korn shell:
         export LIBPATH=$HOME/sqllib/lib32
    • If using C shell:
         setenv LIBPATH $HOME/sqllib/lib32
  3. Run the Java interpreter on the application with this command:
       java TbMod