JDBC/MX 5.0 Driver for SQL/MX Programmer's Reference (SQL/MX 2.x)

java.io.IOException
{
int length = 500;
int recKey;
long start;
long end;
Connection conn1 = null;
// Set jdbcmx.clobTableName System Property. This property
// can also be added to the command line through
// "-Djdbcmx.clobTableName=...", or a
// java.util.Properties object can be used and passed to
// getConnection.
System.setProperty( "jdbcmx.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.sqlmx.SQLMXDriver");
start = System.currentTimeMillis();
conn1 = DriverManager.getConnection("jdbc:sqlmx:");
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;
do {
System.out.println("Messge : " + e.getMessage());
System.out.println("Error Code : " + e.getErrorCode());
System.out.println("SQLState : " + e.getSQLState());
} while ((next = next.getNextException()) != null);
}
// Clob interface example - This technique is suitable when
// the LOB data is already in the app, such as having been
// transferred in a msgbuf.
try {