Updating Java routine classes

If you want to change the logic of a Java™ routine, you must update the routine source code, compile (translate) the code, and then update the version of the Java class or JAR file that is deployed to the database server.

About this task

To ensure that the database manager uses the new version of the Java routine, you must execute a built-in procedure that loads the new version of the Java class into memory.

Procedure

To update Java routine classes:

  1. Deploy the new Java class or JAR file to the database server.
  2. Execute the following built-in procedure for fenced routines:
      CALL SQLJ.REFRESH_CLASSES()
    The CALL SQLJ.REFRESH_CLASSES() statement forces the database manager to load the new class into memory upon the next commit or rollback operation.

    The CALL SQLJ.REFRESH_CLASSES() statement does not affect the unfenced routines. For unfenced routines, you must explicitly stop and restart the database manager in order for new versions of Java routine classes to be loaded and used.

    Note: On a partitioned database system, loading new classes requires you to issue the sqlj.refresh_classes() command on all database partitions. This can be done with the db2_all command. In order for this command to work, you need to connect to the database first, and use \" around the call command. Otherwise a syntax error will appear. This is shown by this example:
    db2_all "db2 connect to sample; db2 \"call sqlj.refresh_classes();\"" 

Results

If you do not perform the steps listed previously, after you update Java routine classes, the database manager will continue to use the previous versions of the classes.