Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
ASCII Data
To insert a CLOB column using ASCII or MBCS data from an InputStream, use the
PreparedStatement interface to insert the CLOB column.
InputStream inputAsciiStream;
PreparedStatement ps = conn.prepareStatement("insert
into myTable (myClobColumn) values (?)");
ps.setAsciiStream(1, inputAsciiStream, length_of_data);
ps.executeUpdate();
The Type 4 driver reads the data from InputStream and writes the data to the LOB table. The
Type 4 driver substitutes the next-available data locator for the parameter of the CLOB column
in the table.
Inserting a Clob Object by Using the setClob Method
Your JDBC application cannot directly instantiate a Clob object. To perform an equivalent
operation:
1. Obtain a Clob object by using the getClob method of the ResultSet interface.
2. Insert the Clob object into another row by using the setClob method of the
PreparedStatement interface.
In this situation, the Type 4 driver generates a new data locator and, when the
PreparedStatement is executed, copies the contents of the source Clob into the new Clob
object.
Reading CLOB Data
Reading ASCII Data from a CLOB Column
To read ASCII or MBCS data from a CLOB column, use the Clob interface or InputStream.
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;
myClobData = new byte[length];
is.read(myClobData, offset, length);
To read ASCII or MBCS 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;
myClobData = new byte[length];
is.read(myClobData, offset, length);
Updating CLOB Data
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.
54 Working with BLOB and CLOB Data