JDBC Driver for SQL/MX Programmer's Reference
Unicode Data
The following code illustrates how to write Unicode data to a CLOB column after obtaining the
handle to the empty CLOB column.
Clob myClob = null;
// stream begins at position 1
long pos = 1;
// Example string containing the Unicode data
String s = TEST_UNICODE_DATA;
// Obtain the output stream to write Clob data
Writer cw = myClob.setCharacterStream(pos);
// write Clob data using Writer
char[] myClobData = s.toCharArray();
cw.write(myClobData);
Inserting CLOB Data by Using the
PreparedStatement Interface
You can use the PreparedStatement interface to insert a CLOB column with data as
follows:
ASCII Data●
Unicode Data●
ASCII Data
You can insert a CLOB column with ASCII or MBCS data from a FileInputSteam. You
must use the PreparedStatement interface to insert the CLOB column.
FileInputStream inputAsciiStream = new
FileInputStream(myClobTestFile);
int clobLen = inputAsciiStream.available();
PreparedStatement ps = conn.prepareStatement("insert
into myTable (myClobColumn) values (?)");
ps.setAsciiStream(1, inputAsciiStream, clobLen);
ps.executeUpdate();
The JDBC/MX driver reads the data from FileInputSteam and writes the data to the LOB
table. The JDBC/MX driver substitutes the next-available data locator for the parameter of the
CLOB column in the table.