Usage example

All Java™ UDT classes must implement the readSQL() and writeSQL() methods for the SQLData interface. The readSQL() method initializes a Java object by using data from the database server in a C-language format. The writeSQL() method converts a Java object back to the representation of the database server. The readSQL() and writeSQL() methods receive a Stream argument that encapsulates the conversion methods for each built-in type that the database server uses, for example, int, float, decimal.

For a fixed-length UDT, the readSQL() and writeSQL() methods know the order and number of fields they are to process. For a variable-length UDT, the programmer must rely on the stream.available() method and/or the SQLException to find the end of the data as this example shows.