Preparing Java routines with no SQLJ clauses and no JAR file

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

About this task

The steps in this task compile source code, add the locations of the resulting class files to the CLASSPATH, define the routine to Db2, and grant access on the routine to users.

Procedure

  1. Run the javac command to compile the Java program to produce Java bytecodes.
  2. 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.

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