Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)

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);
numBytes = iXstream.available();
if (args.length == 3)
numBytes = Integer.parseInt(args[2]);
recKey = Integer.parseInt(args[0]);
System.out.println("Key: " + recKey +"; Using "
+ numBytes + " 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 blobdatatbl");
stmt0.execute("delete from blobtiff");
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 blobtiff values (?,?)";
PreparedStatement stmt1 = conn1.prepareStatement(stmtSource1);
stmt1.setInt(1,recKey);
stmt1.setBinaryStream(2,iXstream,numBytes);
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());
Sample Program Accessing BLOB Data 103