Create UDRs

Using UDR Manager to create UDRs in the database server involves:
  • Coding the UDRs and packaging the code in a JAR file

    For details about coding UDRs, see the HCL® J/Foundation Developer's Guide.

  • Creating a default sbspace in the database server to hold the JAR file that contains the code for the UDR

    For information about creating an sbspace, see the HCL OneDB™ Administrator's Guide for your database server and the HCL J/Foundation Developer's Guide.

  • Calling methods in the UDRMetaData class to specify the information necessary for HCL OneDB JDBC Driver to register the UDRs in the database server
  • If desired, specifying a path name where the driver should place the JAR file in the database server file system
  • Installing the UDRs in the server

Creating a UDR for a C-language opaque type is not supported; the opaque type must be in Java™.

To specify a UDR for the driver to register, use this method in UDRMetaData:
public void setUDR(Method method, String sqlname) throws SQLException

The method parameter specifies an object from java.lang.Reflect.Method to be registered as a Java UDR in the database server. The sqlname parameter is the name of the method as used in SQL statements.

Once you have specified the UDRs to be registered, you can set the JAR file SQL name using UDRMetaData.setJarFileSQLName() and then use the UDRManager.createUDRs() method to install the UDRs in the database server, as follows:
public void createUDRs(UDRMetaData mdata, String jarfile, String
   classname, int deploy) throws SQLException

The jarfile parameter is the absolute or relative path name of the client-side JAR file that contains the Java method definitions. If you use the absolute path name, the JAR file name must be included in your CLASSPATH setting.

The classname parameter is the name of a Java class that contains the methods you want to register as UDRs in the database server. Requirements for preparing the Java methods are described on 1.

For the deploy parameter, see Specify deployment descriptor actions.

The createUDRs() method causes the driver to perform all of the following steps for your application:
  1. Obtain the JAR file designated by the first parameter.
  2. Transport the JAR file from the client local area to the server local area.
  3. Register the UDRs specified in the UDRMetaData object (set through one or more calls to UDRMetaData.setUDR()).
  4. Install the JAR file and create the UDRs in the server.
After createUDRs() executes, your application can use the UDRs in SQL statements.
Important: If your application calls createUDRs() within a transaction, or if your database is ANSI or enables logging, some extra guidelines apply. For more information, see Execute in a transaction.