JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.1 (H06.23+, J06.12+)

Reading Unicode data from a CLOB Column
To read Unicode or MBCS data from a CLOB column, use the CLOB interface or Reader.
Using the
CLOB interface:
// Obtain the Clob from ResultSet
Clob myClob = rs.getClob("myClobColumn");
// Obtain the input stream to read Clob data
Reader cs = myClob.getCharacterStream();
// read Clob data using Reader
char[] myClobData;
myClobData = new char[length];
cs.read(myClobData, offset, length);
To read Unicode data from a CLOB column by using a Reader:
// obtain the Reader from ResultSet
Reader cs = rs.getCharacterStream("myClobColumn");
// read Clob data using the InputStream
char[] myClobData;
myClobData = new char[length];
css.read(myClobData, offset, length);
Updating CLOB Data
Updating Clob Objects with the updateClob Method
Replacing Clob Objects
To update CLOB data, use the methods in the Clob interface or use the updateClob method of the ResultSet interface. The Type 4 driver makes
changes directly to the
CLOB data. Therefore, the Type 4 driver returns false to the locatorsUpdateCopy method of the DatabaseMetaData
interface. Applications do not need to issue a separate update statement to update the CLOB data.
Make updates to
CLOB data in the following ways:
Updating Clob Objects with the updateClob Method
Replacing Clob Objects
Updating Clob Objects with the updateClob Method
Unlike some LOB support implementations, the Type 4 driver updates the CLOB data directly in the database. So, when the Clob object is same
in the
updateClob method as the Clob object obtained using getClob, the updateRow method of the ResultSet interface does nothing with the
Clob object.
When the
Clob objects differ, the Clob object in the updateClob method behaves as if the setClob method was issued. See Inserting a Clob
Object with the setClob Method.
Replacing Clob Objects
You can replace Clob objects in the following ways:
Use the EMPTY_CLOB() function to replace the Clob object with the empty Clob object, then insert new data as described under Inserting
CLOB Columns by Using the Clob Interface.
Use the PreparedStatement.setAsciiStream() or setCharacterStream() method to replace the existing Clob object with new CLOB data.
Use the setClob or updateClob method to replace the existing CLOB objects as explained under Inserting a Clob Object with the setClob
Method and Updating Clob Objects with the updateClob Method.
Deleting CLOB Data
To delete CLOB data, the JDBC application uses the SQL DELETE statement to delete the row in the base table.
When the row containing the
CLOB column is deleted by the JDBC application, the corresponding CLOB data is automatically deleted by the delete
trigger associated with the base table. For information about triggers, see
Using SQL/MX Triggers to Delete LOB Data.
See also
NULL and Empty BLOB or CLOB Value.
Storing BLOB Data
Inserting a BLOB Column by Using the Blob Interface
Writing Binary Data to a BLOB Column
Inserting a BLOB Column by Using the PreparedStatement Interface
Inserting a Blob Object by Using the setBlob Method
Perform operations on BLOB columns that are similar to those operations used on CLOB columns.