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.
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.
cstmt.setBlob(parmIndex, blobData);
byte[] byteData = {(byte)0x1a, (byte)0x2b, (byte)0x3c};
cstmt.setObject(parmInd, byteData, java.sql.Types.BLOB);
java.io.ByteArrayInputStream byteStream =
new java.io.ByteArrayInputStream(byteData);
int numBytes = byteData.length;
cstmt.setBinaryStream(parmIndex, byteStream, numBytes);
cstmt.registerOutParameter(parmIndex, java.sql.Types.BLOB);
cstmt.execute();
byte[] byteData = cstmt.getBytes(parmIndex);
cstmt.setClob(parmIndex, clobData);
String charData = "CharacterString";
cstmt.setObject(parmInd, charData, java.sql.Types.CLOB);
java.io.StringReader reader = new java.io.StringReader(charData);
cstmt.setCharacterStream(parmIndex, reader, charData.length);
byte[] charDataBytes = charData.getBytes("US-ASCII");
java.io.ByteArrayInputStream byteStream =
new java.io.ByteArrayInputStream (charDataBytes);
cstmt.setAsciiStream(parmIndex, byteStream, charDataBytes.length);
cstmt.setString(parmIndex, charData);
If
the length of the data is greater than 32KB, and the JDBC driver has
no DESCRIBE information about the parameter data type, the JDBC driver
assigns the CLOB data type to the input data.cstmt.setObject(parmIndex, charData, java.sql.Types.VARCHAR);
If the length of the data is greater than 32KB, and the
JDBC driver has no DESCRIBE information about the parameter data type,
the JDBC driver assigns the CLOB data type to the input data.cstmt.registerOutParameter(parmIndex, java.sql.Types.CLOB);
cstmt.execute();
Clob clobData = cstmt.getClob(parmIndex);
cstmt.registerOutParameter(parmIndex, java.sql.Types.VARCHAR);
cstmt.execute();
String charData = cstmt.getString(parmIndex);
This technique should be used only if you know that the
length of the retrieved data is less than or equal to 32KB. Otherwise,
the data is truncated.