method as part of an OracleResultSet object getObject() call.
Similarly, the JDBC driver calls your writeSQL() method to write a sequence of data values
from an instance of your custom object class to a stream that can be written to the database.
Typically, the driver would use this method as part of an OraclePreparedStatement object
setObject() call.
*
*
* */
public int h;
public int m;
private String sqlUdt = "MYTIME";
public MyTime(int hh, int mm) {
h = hh;
m = mm;
}
/*The SQLInput implementation is an input stream class, an instance of which must be passed
* in to the readSQL() method.
* Each readXXX() method converts SQL data to Java data and returns it into an output parameter
* of the corresponding Java type. For example, readInt() returns an integer.
* The SQLOutput implementation is an output stream class, an instance of which must be passed
* in to the writeSQL() method. SQLOutput includes a writeXXX() method for each of these Java
* types. Each writeXXX() method converts Java data to SQL data,
* taking as input a parameter of the relevant Java type. For example, writeString() would take
* as input a string attribute from your Java class.
* */
/*You must implement writeSQL() as follows:
public void writeSQL(SQLOutput stream) throws SQLException
The writeSQL() method takes as input a SQLOutput stream.
When your Java application calls setObject(), the JDBC driver creates
a SQLOutput stream object and populates it with data from a custom object
class instance. When the driver calls writeSQL(), it passes in this stream parameter.
For each Java datatype that maps to an attribute of the Oracle object, writeSQL() must
call the appropriate writeXXX() method of the SQLOutput stream that is passed in.
CHAR variable and an employee number as a NUMBER variable, then you must have a writeString()
call and a writeInt() call in your writeSQL() method. These methods must be called according
to the order in which attributes appear in the SQL definition of the Oracle object type.
The writeSQL() method then writes the data converted by the writeXXX() methods to the
SQLOutput stream so that it can be written to the database once you execute the prepared
statement.
*
*
*
* */
public void writeSQL(SQLOutput stream) throws SQLException//Java data to SQL data
{
stream.writeInt(h);
stream.writeInt(m);
}
public String getSQLTypeName() throws SQLException {
return sqlUdt;
}
/* You must implement readSQL() as follows:
public void readSQL(SQLInput stream, String sql_type_name) throws SQLException
The readSQL() method takes as input a SQLInput stream and a string that indicates
the SQL type name of the data (in other words, the name of the Oracle object type,
such as EMPLOYEE).
When your Java application calls getObject(), the JDBC driver creates a SQLInput
stream object and populates it with data from the database. The driver can also determine
the SQL type name of the data when it reads it from the database. When the driver calls
readSQL(), it passes in these parameters.
For each Java datatype that maps to an attribute of the Oracle object, readSQL() must
call the appropriate readXXX() method of the SQLInput stream that is passed in.
For example, if you are reading EMPLOYEE objects that have an employee name as a CHAR
variable and an employee number as a NUMBER vari