JDBC Driver for SQL/MX Programmer's Reference

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 throubh 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
// JdbcMxLobAdmin 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.*;