Using UDT Manager, you can create a Java opaque type from an existing Java class that implements the SQLData interface. UDT Manager can also help you create a Java opaque type without requiring that you have the Java class ready; you specify the characteristics of the opaque type you want to create, and the UDT Manager facility creates the Java class and then the Java opaque type.
Follow the steps in this section to use the UDTManager classes.
For the requirements, see Requirements for the Java Class.
For general information about writing support UDRs, see IBM Informix: User-Defined Routines and Data Types Developer's Guide.
For information about creating an sbspace, see the Administrator's Guide for your database server and the IBM Informix: J/Foundation Developer's Guide.
Make sure a database object is associated with the connection object. The driver cannot create an opaque type without a database object. For details about creating a connection with a database object, see Connecting to the Database.
UDTManager udtmgr = new UDTManager(connection); UDTMetaData mdata = new UDTMetaData();
At a minimum, you must specify the SQL name, UDT length, and JAR file SQL name. For an explanation of SQL names, see SQL Names.
You can also specify the alignment, implicit and explicit casts, and any support UDRs:
mdata.setSQLName("circle2"); mdata.setLength(24); mdata.setAlignment(UDTMetaData.EIGHT_BYTE) mdata.setJarFileSQLName("circle2_jar"); mdata.setUDR(areamethod, "area"); mdata.setSupportUDR(input, "input", UDTMetaData.INPUT) mdata.setSupportUDR(output, "output",UDTMetaData.OUTPUT) mdata.SetImplicitCast(com.informix.lang.IfxTypes.IFX_TYPE_ LVARCHAR, "input"); mdata.SetExplicitCast(com.informix.lang.IfxTypes.IFX_TYPE_ LVARCHAR, "output");
String pathname = "/work/srv93/examples"; udtmgr.setJarFileTmpPath(pathname);
Make sure the path exists in the server file system. For more information, see Specifying a JAR File Temporary Path.
udtmgr.createUDT(mdata, "Circle2.jar", "Circle2", 0);
For additional information on creating an opaque type from existing code, see Creating an Opaque Type from Existing Code.
For a complete code example of using the preceding steps to create an opaque type, see Creating an Opaque Type from an Existing Java Class with UDTManager.
For information about creating an sbspace, see the Administrator's Guide for your database server and the IBM Informix: J/Foundation Developer's Guide.
Make sure the connection object has a database object associated with it. For details, see Connecting to the Database.
UDTManager udtmgr = new UDTManager(connection); UDTMetaData mdata = new UDTMetaData();
mdata.setSQLName("acircle"); mdata.setLength(24); mdata.setFieldCount(3); mdata.setFieldName(1, "x"); mdata.setFieldName(2, "y"); mdata.setFieldName(3, "radius"); mdata.setFieldType (1,com.informix.lang.IfxTypes.IFX_TYPE_INT); mdata.setFieldType (2,com.informix.lang.IfxTypes.IFX_TYPE_INT); mdata.setFieldType (3,com.informix.lang.IfxTypes.IFX_TYPE_INT); mdata.setJarFileSQLName("ACircleJar");
For more information on setting characteristics for opaque types, see Specifying Characteristics for an Opaque Type.
mdata.keepJavaFile(true); String classname = udtmgr.createUDTClass(mdata); String jarfilename = udtmgr.createJar(mdata, new String[] {classname + .class"});
For more information, see Creating the JAR and Class Files.
String pathname = "/work/srv93/examples"; udtmgr.setJarFileTmpPath(pathname);
Make sure the path exists in the server file system. For more information, see Specifying a JAR File Temporary Path.
udtmgr.createUDT(mdata, jarfilename, classname, 0);
For more information, see Sending the Class Definition to the Database Server.
For a complete code example of using the preceding steps to create an opaque type, see Creating an Opaque Type Without an Existing Java Class.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]