DB2 Version 9.7 for Linux, UNIX, and Windows

Building SQLJ applets

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

The following steps demonstrate how to build and run the Applt sample SQLJ applet. 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 applet with this command:
       bldsqlj Applt <userid> <password> <server_name> <port_number> <db_name>
  2. Ensure that your working directory is accessible by your web browser, or by your Java applet viewer, if you are using it. If your directory is not accessible, copy the following files into a directory that is accessible:
    • Applt.html
    • Applt.class
    • Applt_Cursor1.class
    • Applt_Cursor2.class
    • Applt_SJProfileKeys.class
    • Applt_SJProfile0.ser
  3. Copy sqllib\java\db2jcc.jar on Windows or sqllib/java/db2jcc.jar on UNIX, into the same directory as Applt.class and Applt.html.

    If you are using any JDBC 4.0 or later functions, copy db2jcc4.jar instead of db2jcc.jar.

  4. If you are using the IBM® Data Server Driver for JDBC and SQLJ, connect with that driver by modifying the Applt.html file according to the instructions in the file. For the TCP/IP port number, you should use the database port number 50000.
  5. To run this applet, ensure that a web server is installed and running on your DB2 server or client, or use the applet viewer that comes with the SDK for Java by entering the following command in the working directory of your client machine:
       appletviewer Applt.html