Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
// Set hpt4jdbc.clobTableName System Property. This property
// can also be added to the command line through
// "-Dhpt4jdbc.clobTableName=...", or a
// java.util.Properties object can be used and passed to
// getConnection.
System.setProperty( "hpt4jdbc.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.hp.t4jdbc.HPT4Driver");
start = System.currentTimeMillis();
//url should be of the form:
// jdbc:hpt4jdbc://ip_address|host_name:18650/:”
// where host_name is the Neoview database host name
String url = “jdbc:hpt4jdbc://host_name:18650/:”;
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();
}
100 Sample Programs Accessing CLOB and BLOB Data