Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

16.9 Notes on using the BLOB type

This section provides notes about the processing of methods when the BLOB type is used.

Organization of this section
(1) Method processing and notes
(2) Specification method using the ? parameter

(1) Method processing and notes

Table 16-17 describes the processing of each method.

Table 16-17 Method processing and notes

Method name of Blob interface class Processing and notes
getBinaryStream Returns the InputStream class equipped with JdbhInputStream. The maximum length of data that can be acquired is 2,147,483,639.
getBytes(long pos, int length) Returns the maximum length of data from the specified pos location using the byte[] object. If the database contents are the null value, no data can be acquired from the specified location; or if the data length is 0 bytes, the method returns null. The maximum value is 2,147,483,639. If this length is exceeded, the method throws an SQLException.
length() Returns the actual data length.
position(Blob pattern,long start) Executes position(pattern.getBytes(1, (int)(pattern.length())), start). If null is specified in pattern, the method throws a NullPointerException.
position(byte[] pattern,long start) Returns the position corresponding to pattern from the specified start location. The return value is >=start. If there is no location that corresponds to pattern, the method returns -1. The maximum value of pattern.length is 2,147,483,639. If this value is exceeded, the method throws an SQLException. If null is specified in pattern, the method throws a NullPointerException.
setBinaryStream(long pos) Unconditionally throws an SQLException.
setBytes(long pos,byte[] bytes)
setBytes(long pos,byte[] bytes,int offset,int len)
truncate(long len)

Note
If you have acquired data using the locator facility and execute ResultSet.close() or Statement.close(), you can no longer acquire data.

(2) Specification method using the ? parameter

To specify a value in the ? parameter, you can use the PreparedStatement. setBlob() and CallableStatement.setBlob() methods. This subsection provides notes about using these methods.

(a) When using objects equipped with the Blob interface

When using the setBlob() method, you must specify an object equipped with the Blob interface. Additionally, the UAP must create the object equipped with the Blob interface.

JDBC uses the Blob.getBytes() method to acquire the value to be set in the byte[] format. The following method is used to acquire the value to be used:

 
Blob.getBytes(1, (int)(Blob.length()))
 

In the UAP, the getBytes() and length() methods must return normal values. JDBC assumes that the values returned by these methods are correct.

(b) When using the Blob object acquired by the ResultSet.getBlob() or CallableStatement.getBlob() method

When the Blob object acquired by the ResultSet.getBlob() or CallableStatement.getBlob() method as the execution result from JDBC is to be used as is, operation depends on whether or not the object was acquired by using the locator facility for access.