JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1

//
// 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 t4slqmx.blobTableName System Property. This property
// can also be added to the command line through
// "-Dt4slqmx.blobTableName=...", or a
// java.util.Properties object can be used and passed to
// getConnection.
System.setProperty( "t4slqmx.blobTableName","cat.sch.blobdatatbl" );
if (args.length < 2) {
System.out.println("arg[0]=; arg[1]=file; arg[2]=");
return;
}
// byte array for the blob
byte[] whatever = new byte[5000];
for (int i=0; i<5000; i++) whatever[i] = 71; // "G"
String k = "K";
for (int i=0; i<5000; i++) k = k + "K";
System.out.println("string length = " + k.length());
java.io.ByteArrayInputStream iXstream
= new java.io.ByteArrayInputStream(whatever);
114 Sample Programs Accessing CLOB and BLOB Data