JDBC Type 2 Driver Programmer's Reference for SQL/MX Release 3.1 (H06.23+, J06.12+)
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.
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:
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 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 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);










