JDBC Type 4 Driver Programmer's Reference for SQL/MX Release 3.2.1
long end;
Connection conn1 = null;
// Set t4sqlmx.clobTableName System Property. This property
// can also be added to the command line through
// "-Dt4sqlmx.clobTableName=...", or a
// java.util.Properties object can be used and passed to
// getConnection.
System.setProperty( "t4sqlmx.clobTableName","cat.sch.clobdatatbl" );
if (args.length < 2) {
System.out.println("arg[0]=; arg[1]=file;
arg[2]=");
return;
}
String k = "K";
for (int i=0; i<5000; i++) k = k + "K";
System.out.println("string length = " + k.length());
FileInputStream clobFs = new FileInputStream(args[1]);
int clobFsLen = clobFs.available();
if (args.length == 3)
length = Integer.parseInt(args[2]);
recKey = Integer.parseInt(args[0]);
System.out.println("Key: " + recKey +"; Using "
+ length + " of file " + args[1]);
try {
Class.forName("com.tandem.t4jdbc.SQLMXDriver");
start = System.currentTimeMillis();
//url should be of the form:
// jdbc:t4sqlmx://ip_address|machine_name:port_number/:”
String url = “jdbc:t4sqlmx://mymachine:6000/:”;
conn1 = DriverManager.getConnection(url);
System.out.println("Cleaning up test tables...");
Statement stmt0 = conn1.createStatement();
stmt0.execute("delete from clobdatatbl");
stmt0.execute("delete from clobbase");
conn1.setAutoCommit(false);
}
catch (Exception e1) {
e1.printStackTrace();
}
// PreparedStatement interface example - This technique
// is suitable if the LOB data is already on the NonStop
// system disk.
try {
System.out.println("PreparedStatement interface
LOB insert..."); String stmtSource1 = "insert into clobbase
values (?,?)";
PreparedStatement stmt1
= conn1.prepareStatement(stmtSource1);
stmt1.setInt(1,recKey);
stmt1.setAsciiStream(2,clobFs,length);
stmt1.executeUpdate();
conn1.commit();
}
catch (SQLException e) {
e.printStackTrace();
SQLException next = e;
112 Sample Programs Accessing CLOB and BLOB Data