Preparing Java routines with SQLJ clauses and no JAR file

If you do not use a JAR file for a Java routine that contains SQLJ clauses, you need to include the directories for the routine classes in the CLASSPATH.

About this task

The steps in this task prepare an SQLJ routine for execution, specify the class files for the routine in the CLASSPATH, define the routine to Db2, and grant access on the routine to users.

Procedure

  1. Run the sqlj command to translate the source code to produce generated Java source code and serialized profiles, and to compile the Java program to produce Java bytecodes.
  2. Run the db2sqljcustomize command to produce serialized profiles that are customized for Db2 for z/OS® and Db2 packages.
  3. Ensure that the zFS or HFS directory that contains the class files for your routine is in the CLASSPATH for the WLM-established stored procedure address space.

    You specify this CLASSPATH in the JAVAENV data set. You specify the JAVAENV data set using a JAVAENV DD statement in the startup procedure for the WLM-established stored procedure address space.

    If you need to modify the CLASSPATH environment variable in the JAVAENV data set to include the directory for the Java routine's classes, you must restart the WLM address space to make it use the modified CLASSPATH.

  4. Use the SQL CREATE PROCEDURE or CREATE FUNCTION statement to define the routine to Db2. Specify the EXTERNAL NAME parameter without a JAR name.
  5. Execute the SQL GRANT statement to grant the EXECUTE privilege on the routine to the appropriate users.