NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)
BLOBs and CLOBs
A BLOB is used to represent a Binary Large OBject. A CLOB is used to represent a Character Large OBject. BLOBs are
typically used to store images (such as GIFs) or serialized objects into the database. CLOBs are typically used to store large
character data into the database (such as an XML file).
Because SQL/MP does not support either the Clob or the Blob data type, JDBC provides an alternative method that stores
the contents of a BLOB or CLOB in an Enscribe file and stores the name of that file in the column associated with the BLOB
or CLOB. From the point of view of the JDBC user, a BLOB or CLOB is any Java object that extends from the
java.lang.Object class. BLOBs and CLOBs must, however, be serializable objects and must implement the
java.io.Serializable interface. This enables the JDBC driver to do the following:
Serialize a BLOB or CLOB object into an array of bytes to be stored in a BLOB/CLOB file.●
Deserialize the contents of the BLOB/CLOB file to re-create the original object.●
Because the JDBC driver creates and reads BLOBs and CLOBs in the same manner, the rest of this description will refer only
to BLOBs. You define a CLOB in exactly the same manner as a BLOB, and use the BLOB syntax.
SQL/MP Table Definition
If you want to use the Blob data type, you must define a column in the associated SQL/MP table to store the name of the
Enscribe file associated with that BLOB. The data type of the column should be either CHARACTER or VARCHAR and must be
long enough to store the Enscribe file name (at least 36 characters long).
Creating a BLOB
A client JDBC application that needs to store a BLOB in a SQL/MP database table or to retrieve a BLOB from a SQL/MP
database table will provide a java.util.Properties object to the JDBC driver during connection time. This Properties
object will be used to provide the driver with all the information it needs to create or read the BLOB. An additional property is
required called a BlobMapFile property. This property is used to specify a unique file name in the
$volume.subvolume.filename format. This file is used to store a list of all the BLOB files created by a particular
application. This file is later used by the Cleanup Utility to remove obsolete blob files.
BlobInfo Properties
BlobInfo properties are used to provide information about all table columns that are used to store BLOBs. Each BlobInfo
property consists of a key and value pair. The key is used to identify a unique BlobInfo property while the value specifies a
particular BLOB column in a table, the catalog for that table, and file locations where BLOB files should be created.
The Properties object should contain one 'BlobInfo' property for every table column that contains BLOBs. A BlobInfo
property is identified by a key of type 'BlobInfoN', where N represents a unique number used to identify that property.
Format of a BlobInfo property
The format of a BlobInfo property is as follows:
BlobInfoN, sqlmp_table_name, column_name, sqlmp_catalog_of_Blob_table, $vol.subvol [,
... ]
where
N
is a unique number used to identify the BlobInfo property
sqlmp_table_name
is the name of the BLOB table
column_name
is the name of the column to be associated with the BLOB. This column should be defined to SQL/MP as CHAR or
VARCHAR 36
sqlmp_catalog
is the name of the catalog associated with the BLOB table
$vol.subvol [, ... ]