Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)

Sample Program Accessing BLOB Data
This sample program shows the use of both the Blob interface and the PreparedStatement
interface to take a byte variable and put the variable's value into a base table that has a BLOB
column.
// LOB operations may be performed through the Blob, or
// PreparedStatement interface. This program shows examples of
// using both interfaces taking a byte[] variable and putting
// it into the cat.sch.blobtiff table.
//
// The LOB base table for this example is created as:
// >> create table blobtiff
// (col1 int not null not droppable,
// tiff blob, primary key (col1));
//
// The LOB table for this example is created through the
// T4LobAdmin utility as:
// >> create table cat.sch.blobdatatbl
// (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 blob interface...
// - insert the base row with EMPTY_BLOB() 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 prep stmt 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 TestBLOB 1 TestBLOB.class 1000
//
import java.sql.*;
import java.io.*;
public class TestBLOB
{
public static void main (String[] args)
throws java.io.FileNotFoundException, java.io.IOException
{
int numBytes;
int recKey;
long start;
long end;
Connection conn1 = null;
// Set hpt4jdbc.blobTableName System Property. This property
// can also be added to the command line through
// "-Dhpt4jdbc.blobTableName=...", or a
// java.util.Properties object can be used and passed to
// getConnection.
System.setProperty( "hpt4jdbc.blobTableName","cat.sch.blobdatatbl" );
102 Sample Programs Accessing CLOB and BLOB Data