IBM DB2 Manual page 69

Table of Contents

Advertisement

ResultSet.updateBlob(int columnIndex, InputStream x)
ResultSet.updateBlob(String columnLabel, InputStream x)
ResultSet.updateBinaryStream(int columnIndex, InputStream x)
ResultSet.updateBinaryStream(String columnLabel, InputStream x)
PreparedStatement.setBlob(int columnIndex, InputStream x)
PreparedStatement.setBlob(String columnLabel, InputStream x)
PreparedStatement.setBinaryStream(int columnIndex, InputStream x)
PreparedStatement.setBinaryStream(String columnLabel, InputStream x)
v Create a Blob or Clob object that contains no data, using the
Connection.createBlob or Connection.createClob method.
v Materialize a Blob or Clob object on the client, when progressive streaming or
locators are in use, using the Blob.getBinaryStream or Clob.getCharacterStream
method.
v Free the resources that a Blob or Clob object holds, using the Blob.free or
Clob.free method.
Java data types for retrieving or updating LOB column data in
JDBC applications
When the JDBC driver cannot immediately determine the data type of a parameter
that is used with a LOB column, you need to choose a parameter data type that is
compatible with the LOB data type.
For IBM Data Server Driver for JDBC and SQLJ type 2 connectivity to DB2 for
z/OS, when the JDBC driver processes a CallableStatement.setXXX call for a
stored procedure input parameter, or a CallableStatement.registerOutParameter
call for a stored procedure output parameter, the driver cannot determine the
parameter data types.
When the deferPrepares property is set to true, and the IBM Data Server Driver for
JDBC and SQLJ processes a PreparedStatement.setXXX call, the driver might need
to do extra processing to determine data types. This extra processing can impact
performance.
Input parameters for BLOB columns
For input parameters for BLOB columns, or input/output parameters that are used
for input to BLOB columns, you can use one of the following techniques:
v Use a java.sql.Blob input variable, which is an exact match for a BLOB column:
cstmt.setBlob(parmIndex, blobData);
v Use a CallableStatement.setObject call that specifies that the target data type is
BLOB:
byte[] byteData = {(byte)0x1a, (byte)0x2b, (byte)0x3c};
cstmt.setObject(parmInd, byteData, java.sql.Types.BLOB);
v Use an input parameter of type of java.io.ByteArrayInputStream with a
CallableStatement.setBinaryStream call. A java.io.ByteArrayInputStream
object is compatible with a BLOB data type. For this call, you need to specify the
exact length of the input data:
java.io.ByteArrayInputStream byteStream =
new java.io.ByteArrayInputStream(byteData);
int numBytes = byteData.length;
cstmt.setBinaryStream(parmIndex, byteStream, numBytes);
Output parameters for BLOB columns
For output parameters for BLOB columns, or input/output parameters that are
used for output from BLOB columns, you can use the following technique:
Chapter 3. JDBC application programming
53

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents