Home | Previous Page | Next Page   Working with Opaque Types > Creating Opaque Types and UDRs >

Creating UDRs

Using UDR Manager to create UDRs in the database server involves:

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 pathname of the client-side JAR file that contains the Java method definitions. If you use the absolute pathname, the JAR filename 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 page 1.

For the deploy parameter, see Specifying 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 Executing in a Transaction.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]