JDBC Type 2 Driver Programmer's Reference for SQL/MX Release 3.2.1 (H06.26+, J06.15+)

Reading ASCII Data from a CLOB Column
You can read ASCII or Unicode data from a CLOB column by using the Clob interface or
InputStream.
The following code illustrates how to read the ASCII data from the CLOB column by using the Clob
interface:
// Obtain the Clob from ResultSet
Clob myClob = rs.getClob("myClobColumn");
// Obtain the input stream to read Clob data
InputStream is = myClob.getAsciiStream();
// read Clob data using the InputStream
byte[] myClobData = new byte[length];
int readLen = is.read(myClobData, offset, length);
To read ASCII or Unicode data from the CLOB column by using InputStream:
// obtain the InputStream from ResultSet
InputStream is = rs.getAsciiStream("myClobColumn");
// read Clob data using the InputStream
byte[] myClobData = new byte[length];
int readLen = is.read(myClobData, offset, length);
Reading Unicode Data from a CLOB Column
You can read Unicode data from the CLOB column by using the Clob interface or Reader. The
following code illustrates how to read the Unicode data from the CLOB column by 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 = new char[length];
int readLen = cs.read(myClobData, offset, length);
To read Unicode data from the CLOB column by using a Reader:
// obtain the Reader from ResultSet
Reader cs = rs.getCharacterStream("myClobColumn");
// read Clob data using the InputStream
char[] myClobData = new char[length];
int readLen = cs.read(myClobData, offset, length);
Updating CLOB Data
You can make updates to CLOB data by using the methods in the Clob interface or by using the
updateClob method of the ResultSet interface. The JDBC/MX driver makes changes directly
to the CLOB data. Therefore, the JDBC/MX 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” (page 48)
“Replacing Clob Objects (page 49)
Updating Clob Objects with the updateClob Method
Unlike some LOB support implementations, the JDBC/MX driver updates the CLOB data directly
in the database. So, when the Clob object is the 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.
48 Working with BLOB and CLOB Data