Requirements for the Java class

To qualify for converting into an opaque type, your Java™ class must meet the following conditions:
  • The class must implement the java.sql.SQLData interface. For an example, see Examples.
  • If the class contains another opaque type, the additional opaque type must be implemented in a similar way and the additional .class file must be packaged as part of the same JAR file as the original opaque type.
  • If the class contains DISTINCT types, the class can either implement the SQLData interface for the DISTINCT types or let the driver map the DISTINCT types to the base types. For more information, see Distinct data types.
  • The class cannot contain complex types.
  • If you are creating an opaque type from an existing Java class and using the default support functions in the database server, you must cast the SQLInput and SQLOutput streams in SQLData.readSQL() and SQLData.writeSQL() to IfmxUDTSQLInput and IfmxUDTSQLOutput.

    For a code example that shows how to do this, see Create an opaque type using default support functions.

  • All Java methods for the opaque type must be in the same .java file with the class that defines the opaque type.
Additional requirements for UDRs are as follows:
  • All class methods to be registered as UDRs must be static.
  • The method argument types and the return types must be valid Java data types.
  • The methods can use all basic nongraphic Java packages that are included in the Java development kit, such as java.util, java.io, java.net, java.rmi, java.sql, and so forth.
  • Data types of method arguments and return types must conform to the data type mapping tables shown in Data type mapping for UDT manager and UDR manager.
  • The following SQL argument or return types are not supported:
    • MONEY
    • DATETIME with qualifier other than hour to second or year to fraction(5)
    • INTERVAL with qualifier other than year to month or day to fraction(5)
    • Any data type not shown in the mapping tables for method arguments and return types; for the tables, see Data type mapping for UDT manager and UDR manager.