To implement a complete UDT in Java code, you must supply a set of data-formatting methods that convert to and from the various representations of the data type. These methods perform input and output operations for the data type such as converting text input to the internal structure that the database server uses.
All the database server I/O functions manipulate data formats that can be represented as Java streams. The streams encapsulate the data and implement methods needed to parse the source format or write the destination format.
For example, after creating the UDT Record3 with the following statements:
create opaque type Record3 (internallength = variable, alignment = 8, maxlen = 2048, cannothash ); grant usage on type Record3 to public; execute procedure setUDTExtName("Record3", "informix.testclasses.jlm.udt.Record3");
you could create the default casts and I/O functions with the following statement:
execute procedure registerJUDTfuncs("Record3");
The readSQL() method converts a database type to a Java object and the writeSQL() method converts a Java object to the database type. The system supplies the appropriate stream type at runtime.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]