NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.1+)

error ##
is the file system error returned while reading the BLOB from a BLOB file.
Note: Retrieving a BLOB from a database runs as a waited operation, so reading a BLOB within a thread blocks
that thread.
Example of Retrieving a BLOB From the Database
This example assumes that a java.util.Properties object with BLOB properties has been created as described in the
previous example and a connection granted using this Properties object. The sample table $VOL2.MYVOL.EMPLOYEE
contains two columns:
EMPNAME
stores an employee's name.
EMPPIC
stores an employee's picture.
java.lang.String selectString = new String("SELECT * FROM $VOL2.MYVOL.EMPLOYEE");
// create a Statement object for the connection
stmt = conn.createStatement( );
// get a ResultSet with the contents of the table.
ResultSet results = stmt.executeQuery(selectString);
//retrieve content of first row
String name = results.getString(1);
Object blob = results.getObject(2);
Note: The BLOB can also be retrieved as an array of bytes instead of as an object, as follows:
byte[ ] blob_contents = results.getBytes(2);
Removing Obsolete BLOB Files
A Cleanup utility is provided to periodically remove obsolete BLOB files from the file system. BLOB files become obsolete as
a result of one of the following operations:
An application updates a BLOB column. The driver creates a new BLOB file to store the new BLOB object. It then
writes the name of the new BLOB file in the table. The BLOB file containing the original BLOB now becomes obsolete.
The application deletes a row containing a BLOB from the table. The BLOB file name is removed from the table and is
not referenced by any other tables. The BLOB file is now obsolete.
The Cleanup utility uses a BLOB map file. The JDBC driver adds an entry for every BLOB file created by an application to
this BLOB map file. During cleanup, the JDBC driver deletes all obsolete BLOB files from the file system and their
corresponding entries from the BLOB map file.
The Cleanup utility can be run only by the owner of the BLOB map file. It is the responsibility of the owner of the application
to run the Cleanup utility to remove any obsolete BLOB files that have been created for it from the file system. To maintain the
integrity of the application's database tables, run this utility ONLY when none of the affected tables containing BLOBs are in
use. The Cleanup utility is a Java application that should be run from the command line in the following way:
java com.tandem.sqlmp.SQLMPBlobCleanup [errfile]
where:
com.tandem.sqlmp.SQLMPBlobCleanup
is the Cleanup utility
Blob map file
is the name of the BLOB map file specified by the application.
errfile