Install a JAR file

JAR files contain the code for the UDRs. For an SQL statement to be able to include a UDR written in Java code, you must install the JAR file in the current database. When a JAR file is installed, the routine manager of the database server can load the appropriate Java class when the UDR is invoked.

To install a JAR file on HCL Informix®, the JAR file must be have READ permissions for user informix.

If the IFX_EXTEND_ROLE configuration parameter is set to 'On' or 1, authorization to use the built-in routines that manipulate shared objects is available only to the Database Server Administrator, and to users to whom the DBSA has granted the EXTEND role. For HCL Informix® 10.00.xC4 and later releases, IFX_EXTEND_ROLE is enabled by default.

For databases in which this security feature is not needed, see the description of IFX_EXTEND_ROLE in your Informix® Administrator's Reference for information about how the DBSA can disable this configuration parameter by resetting it.

To manage JAR files, use the EXECUTE PROCEDURE statement with the following SQLJ built-in procedures:
  • sqlj.install_jar(jar_url varchar(255), jar_id varchar(255), deploy_flag int)

    Before a Java static method can be mapped to a UDR, the class file that defines the method must be installed in the database. The install_jar() procedure installs a Java JAR file in the current database and assigns it a JAR identifier (or JAR ID) for use in subsequent CREATE FUNCTION or CREATE PROCEDURE statements.

    For example:
    -- Installing a jar file
    EXECUTE PROCEDURE sqlj.install_jar
     ('file:$INFORMIXDIR/jars/admin.jar', 
      'admin_jar', 1);
  • sqlj.replace_jar(jar_url varchar(255), jar_id varchar(255))

    The replace_jar() procedure replaces a previously installed JAR file with a new version.

  • sqlj.remove_jar(jar_id varchar(255), undeploy_flag int)

    The remove_jar() procedure removes a previously installed JAR file from the current database.

  • sqlj.alter_java_path(jar_id varchar(255), path lvarchar)

    The alter_java_path() procedure specifies the java-file search path to use when the routine manager resolves related Java classes for the JAR file of a UDR.

For details about jar-naming conventions, see the SQLJ: SQL Routines specification.

All SQLJ built-in procedures are in the sqlj schema.

Both sqlj.install_jar() and sqlj.remove_jar() take a parameter that, when set appropriately, causes the procedure to execute the deployment descriptor files in the JAR file.

For more information about how to install JAR files, see the SQLJ: SQL Routines specification.

The SQLJ: SQL Routines specification has detailed tutorials on writing, registering, installing, and calling routines written in Java code.