JAR file administration on the database server

To deploy JAR files that contain Java™ routine class files, you must install the JAR file to the database server. This can be done from an IBM® Data Server Client by using built-in routines that install, replace, or remove JAR files on the database server.

To install, replace, or remove a JAR file in a database instance, use the stored procedures that are provided with the database product:
Install
sqlj.install_jar( jar-url, jar-id )
Note: The privileges held by the authorization ID of the caller of sqlj.install_jar must include at least one of the following:
  • CREATEIN privilege for the implicitly or explicitly specified schema
  • DBADM authority
sqlj.db2_install_jar( jar-locator, jar-id )
Replace
sqlj.replace_jar( jar-url, jar-id )
sqlj.db2_replace_jar( jar-locator, jar-id )
Remove
sqlj.remove_jar( jar-id )
  • jar-url: The URL containing the JAR file to be installed or replaced. The only URL scheme supported is 'file:'.
  • jar-id: A unique string identifier, up to 128 bytes in length. It specifies the JAR identifier in the database associated with the jar-url file.
  • jar-locator: A BLOB locator input parameter that points to the JAR file that is to be installed in the Db2® catalog.
Note: When invoked from applications, the stored procedures sqlj.install_jar and sqlj.remove_jar have an additional parameter. It is an integer value that dictates the use of the deployment descriptor in the specified JAR file. At present, the deployment parameter is not supported, and any invocation specifying a nonzero value will be rejected.

Following are a series of examples of how to use the preceding JAR file management stored procedures.

To register a JAR located in the path /home/bob/bobsjar.jar with the database instance as MYJAR:
CALL sqlj.install_jar( 'file:/home/bob/bobsjar.jar', 'MYJAR' )
Subsequent SQL commands that use the bobsjar.jar file refer to it with the name MYJAR.
To replace MYJAR with a different JAR containing some updated classes:
CALL sqlj.replace_jar( 'file:/home/bob/bobsnewjar.jar', 'MYJAR' )
To remove MYJAR from the database catalogs:
CALL sqlj.remove_jar( 'MYJAR' )
Note: On Windows operating systems, the database stores JAR files in the path that is specified by the DB2INSTPROF instance-specific registry setting. To make JAR files unique for an instance, you must specify a unique value for DB2INSTPROF for that instance.
Note: On a partitioned database system, the command sqlj.install_jar() only installs the JAR file on the node issuing the command. Run sqlj.replace_jar() on each node to copy the jar file.