Neoview JDBC Type 4 Driver Programmer's Reference (R2.2, R2.3, R2.4, R2.5)
} while ((next = next.getNextException()) != null);
}
// Blob interface example - This technique is suitable when
// the LOB data is already in the app, such as having been
// transfered in a msgbuf.
try {
// insert a second base table row with empty LOB column
System.out.println("BLOB interface LOB insert...");
String stmtSource2 = "insert into blobtiff
values (?,EMPTY_BLOB())";
PreparedStatement stmt2 = conn1.prepareStatement(stmtSource2);
stmt2.setInt(1,recKey+1);
stmt2.executeUpdate();
Blob tiff = null;
System.out.println("Obtaining BLOB data to
update (EMPTY in this case)...");
PreparedStatement stmt3 = conn1.prepareStatement("select tiff
from blobtiff where col1 = ? for update");
stmt3.setInt(1,recKey+1);
ResultSet rs = stmt3.executeQuery();
if (rs.next()) tiff = rs.getBlob(1); // has to be there
else the base table insert failed
System.out.println("Writing data to previously
empty BLOB...");
OutputStream os = tiff.setBinaryStream(1);
byte[] bData = k.getBytes();
os.write(bData);
os.close();
conn1.commit();
}
catch (SQLException e) {
e.printStackTrace();
SQLException next = e;
do {
System.out.println("Messge : " + e.getMessage());
System.out.println("Vendor Code : " + e.getErrorCode());
System.out.println("SQLState : " + e.getSQLState());
} while ((next = next.getNextException()) != null);
}
} // main
} // class
104 Sample Programs Accessing CLOB and BLOB Data