JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.1 (H06.23+, J06.12+)

CLOB clobTableName
For more information about using these properties, see LOB Table Name Properties.
Reserving Data Locators
A data locator is the reference pointer value (SQL LARGEINT data type) that is substituted for the BLOB or CLOB column in the base table definition.
Each object stored into the LOB table is assigned a unique data locator value. Because the LOB table is a shared resource among all accessors
that use the particular LOB table, reserving data locators reduces contention for getting the next value. The default setting is 100 reserved data
locators; therefore, each JVM instance can insert 100 large objects (not chunks) before needing a new allocation.
Specify the number of data locators (
n) to reserve for your application by using the Type 4 driver property t4sqlmx.reserveDataLocators. For
information about specifying this property, see
reserveDataLocators Property.
Storing CLOB Data
Inserting CLOB Columns by Using the Clob Interface
Writing ASCII or MBCS Data to a CLOB Column
Inserting CLOB Data by Using the PreparedStatement Interface
Inserting a Clob Object by Using the setClob Method
Inserting CLOB Columns by Using the Clob Interface
When you insert a row containing a CLOB data type, and before the column can be updated with real CLOB data, you can insert a row that has an
empty
CLOB value. To insert an empty CLOB value in a NonStop SQL/MX database, specify the EMPTY_CLOB() function for the CLOB column in the
insert statement.
Note:
The EMPTY_CLOB() function is an HP NonStop specific function and might not work on other databases.
Do not use the EMPTY_CLOB() function when using the PreparedStatement interface.
The Type 4 driver scans the SQL string for the EMPTY_CLOB() function and substitutes the next-available data locator.
Then, obtain the handle to the empty
CLOB column by selecting the CLOB column for update. The following code illustrates how to obtain the
handle to an empty
CLOB column:
Clob myClob = null;
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("Select myClobColumn
from myTable where ….for update");
if (rs.next())
myCLOB = rs.getClob(1);
You can now write data to the CLOB column. See Writing ASCII or Unicode Data to a CLOB Column.
Note: Limitation: Do not rename the CLOB column in the select query.
Writing ASCII or MBCS Data to a CLOB Column
You can write ASCII or MBCS data to a CLOB column.
Note: Multibyte Character Set (MBCS) data and ASCII data are handled the same way.
ASCII Data
To write ASCII or MBCS data to the CLOB column, use the Clob interface. The following code illustrates using the setAsciiStream method of the
Clob interface to write CLOB data.
// stream begins at position: 1
long pos = 1;
//String containing the ASCII data
String s ;
// Obtain the output stream to write Clob data
OutputStream os = myClob.setAsciiStream(pos);
// write Clob data using OutputStream
byte[] myClobData = s.getBytes();
os.write(myClobData);
The Type 4 driver splits the output stream into chunks and stores the chunks in the LOB table.
Inserting CLOB Data by Using the PreparedStatement Interface