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

// add BlobInfo Properties
prop.put("BlobInfo1", ","$VOL1.MYVOL.PRODUCT, PICTURE, $VOL.CTLG, $VOL1.SUBVOL1, \
> $VOL2.SUBVOL2");
prop.put("BlobInfo2", ","$VOL2.MYVOL.EMPLOYEE, EMPPIC, $VOL.CTLG, $VOL2.SUBVOL2");
");//add BlobMapFile Property
prop.put("BlobMapFile", ","$VOL2.MYVOL.BLOBMAP");
");// add other properties to java.util.Properties object.....
The BLOB table name, column name, and catalog name are required by JDBC. At least one file location per BlobInfo
property is required to provide BLOB support. If more than one file location is provided, the JDBC driver searches through the
list of file locations when creating BLOB files.
Note: The table name and catalog name must be provided in the $volume.subvolume format. Aliases for
table names or catalog names cannot be substituted for BLOB properties.
The Properties object can also contain other connection-related properties and their values, such as logon ID, password, alias,
and so on. The Properties object can also be created by loading the properties from a file. In either case, the format for all
BLOB properties must be the same.
Note: After a Properties object has been specified while creating a database connection, the connection is aware
of only those BLOB properties specified during connection creation. Any changes or updates made to the
Properties object after the connection has been granted are invisible to that connection.
The JDBC drivers use the specified Properties object to ascertain which columns will be used for storing BLOBs for every
table the application will use. The JDBC drivers use the BLOB properties to decide if the object to be stored or retrieved is a
BLOB. The BLOB properties are also used to decide the location where a BLOB file should be created for a particular BLOB
column in a table.
The JDBC drivers also provide some preliminary error checking on the BLOB properties. The error checking ensures that all
information required in a BlobInfo property has been provided, and that all file names and file locations are in the correct
$volume.subvolume format.
After a connection to the database has been granted to an application, the application can then use JDBC to access and use
BLOBs as it would any other SQL/MP supported data type. Client applications can use JDBC to:
Write a BLOB to a database table
Retrieve a BLOB from a database table
Update a BLOB stored in a database table
Delete a row containing a BLOB from a database table
Writing a BLOB to the Database
A JDBC application can write a BLOB to the database using the setObject( ) method in the PreparedStatement
interface. Using the SQL/MP JDBC Driver, a BLOB can be written to a database table using any of the following methods
supported by SQLMPPreparedStatement:
public void setObject(int parameterIndex, Object x, int targetSqLType, int scale)
public void setObject(int parameterIndex, Object x, int targetSqLType)
public void setObject(int parameterIndex, Object x)
where:
parameterIndex
is the parameter to be set.
x
is any serializable Java object.
targetSqlType
should be java.sql.Types.OTHER
scale
is ignored for BLOBs.