JDBC Driver for SQL/MX Programmer's Reference
Unicode Data
You can insert a CLOB column with Unicode data from a FileReader. You must use the
PreparedStatement interface to insert the CLOB column.
FileReader inputReader = new FileReader(myClobTestFile);
PreparedStatement ps = conn.prepareStatement("insert
into myTable (myClobColumn) values (?)");
ps.setCharacterStream(1, inputReader,
(int)myClobTestFile.length());
ps.executeUpdate();
The JDBC/MX driver reads the data from FileReader 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.
Inserting a Clob Object by Using the setClob
Method
Your JDBC application cannot directly instantiate a Clob object. To perform an equivalent
operation:
Obtain a Clob object by using the getClob method of the ResultSet interface.1.
Insert the Clob object into another row by using the setClob method of the
PreparedStatement interface.
2.
In this situation, the JDBC/MX 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●
Reading Unicode Data from a CLOB Column●
Reading ASCII Data from a CLOB Column
You can read ASCII or MBCS 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: