DB2 Version 9.7 for Linux, UNIX, and Windows

Building SQL routines

You can use a Java™ makefile or the bldsqljs build file to build SQLJ routines. After you build those routines, you need to catalog them.

About this task

The following steps demonstrate how to build and run the SpServer sample SQLJ stored procedure. These steps use the build file, bldsqljs (UNIX), or bldsqljs.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.

Procedure

  1. Build the stored procedure application with this command:
       bldsqljs SpServer <userid> <password> <server_name> <port_number> <db_name>
  2. Catalog the stored procedure with this command:
       spcat
    This script connects to the sample database, uncatalogs the routines if they were previously cataloged by calling SpDrop.db2, then catalogs them by calling SpCreate.db2, and finally disconnects from the database. You can also run the SpDrop.db2 and SpCreate.db2 scripts individually.
  3. Stop and restart the database to allow the new class file to be recognized. If necessary, set the file mode for the class file to read, so it is readable by the fenced user.
  4. Compile and run the SpClient client application to access the stored procedure class. You can build SpClient with the application build file, bldsqlj (UNIX) or bldsqlj.bat (Windows).