public interface SQLData
Usually within an implementation of
SQLData, there is a corresponding
field for every attribute of an SQL type, but only one field, if the type is
DISTINCT. When the UDT is returned within a
is accessed with the
ResultSet.getObject(int) method and is returned as an
object which is an instance of the class defined by the
mapping. The application can use this object just like any other Java object
and can store changes back into the database using the
PreparedStatement.setObject(int, java.lang.Object) method which performs the reverse mapping
into the SQL
Normally the implementation of a custom mapping is generated by
a tool requiring the name of the SQL
UDT, the name
of the class which it is going to be mapped to, and the field names to which
the UDT attributes are mapped. The tool can then implement the
attributes from an
SQLInput object, and
writeSQL writes them.
This is done via
SQLOutput method calls
Ordinarily an application would not call
SQLData methods directly.
SQLOutput methods are not usually
|Modifier and Type||Method and Description|
Gets the SQL name of the User Defined Type (UDT) that this object represents.
Reads data from the database into this object.
Writes the object to a supplied
String getSQLTypeName() throws SQLException
readSQLwhen the object was created.
SQLException- if a database error occurs.
void readSQL(SQLInput stream, String typeName) throws SQLException
SQLInputreadBigDecimal). If the type is distinct, then read its only data entry. For structured types, read every entry.
The supplied input stream is typically initialized by the calling JDBC
driver with the type map before
readSQL is called.
void writeSQL(SQLOutput stream) throws SQLException
SQLOutputdata stream, writing it out as an SQL value to the data source.
This method follows the following steps:
writeString). Write a single data element for a distinct type. For a structured type, write a value for each attribute of the the SQL type.