Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
A Sample Programs Accessing CLOB and BLOB Data
This appendix shows two working programs.
Sample Program Accessing CLOB Data
This sample program shows operations that can be performed through the Clob interface or
through the PreparedStatement interface. The sample program shows examples of both
interfaces taking a variable and putting the variable's value into a base table that has a CLOB
column.
// LOB operations can be performed through the Clob interface,
// or the PreparedStatement interface.
// This program shows examples of both interfaces taking a
// variable and putting it into the cat.sch.clobbase table.
//
// The LOB base table for this example is created as:
// >> create table clobbase
// (col1 int not null not droppable,
// col2 clob, primary key (col1));
//
// The LOB table for this example is created through
// the T4LobAdmin utility as:
// >> create table cat.sch.clobdatatbl
// (table_name char(128) not null not droppable,
// data_locator largeint not null not droppable,
// chunk_no int not null not droppable,
// lob_data varchar(3880),
// primary key(table_name, data_locator, chunk_no))
// attributes extent(1024), maxextents 768 ;
//
// ***** The following is the Clob interface...
// - insert the base row with EMPTY_CLOB() as value for
// the LOB column
// - select the LOB column 'for update'
// - load up a byte[] with the data
// - use Outputstream.write(byte[])
//
// ***** The following is the PreparedStatement interface...
// - need an Inputstream object that already has data
// - need a PreparedStatement object that contains the
// 'insert...' DML of the base table
// - ps.setAsciiStream() for the lob data
// - ps.executeupdate(); for the DML
//
// To run this example, issue the following:
// # java TestCLOB 1 TestCLOB.java 1000
//
import java.sql.*;
import java.io.*;
public class TestCLOB
{
public static void main (String[] args)
throws java.io.FileNotFoundException,
java.io.IOException
{
int length = 500;
int recKey;
long start;
long end;
Connection conn1 = null;
Sample Program Accessing CLOB Data 99