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

Creating the JAR and Class Files

Once you have specified the characteristics of the opaque type through the UDTMetaData methods, you can use the methods in the UDTManager class to create opaque types and their class and JAR files in the following order:

  1. Instantiate the UDTManager object.

    The constructor is defined as follows:

    public UDTManager(Connection conn) throws SQLException
  2. Create the .class and .java files with the createUDTClass() method.
  3. Create the .jar file with the createJar() method.
  4. Create the opaque type with the createUDT() method.

Creating the .class and .java Files

The createUDTClass() method has the following signature:

public String createUDTClass(UDTMetaData mdata) throws SQLException

The createUDTClass() method causes the driver to perform all of the following actions for your application:

  1. Creates a Java class with the name you specified in the UDTMetaData.setClassName() method

    If no class name was specified, the driver uses the name specified in the UDTMetaData.setSQLName() method.

  2. Puts the Java class code into a .java file and then compile the file to a .class file
  3. Returns the name of the newly created class to your application

If you specified TRUE by calling the UDTMetaData.keepJavaFile() method, the driver retains the generated .java file. The default is to delete the .java file.

Your application should call the createUDTClass() method only to create new .class and .java files to define an opaque type, not to generate an opaque type from existing files.

Creating the .jar File

The createJar() method compiles the class files you specify in the classnames list. The files in the list must have the .class extension.

public String createJar(UDTMetaData mdata, String[] classnames) 
   throws SQLException;

The driver creates a JAR file named sqlname.jar (where sqlname is the name you specified by calling UDTMetaData.setSQLName()) and returns the filename to your application.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]