I got the following error when I used setBinaryStream to set a Blob field using callablestatement.


COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0171N The data type, length or value of argument "2" of routine "SP_STOREOUTPUTDATA" is incorrect. SQLSTATE=42815

at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java:260)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_S QLException(SQLExceptionGenerator.java:197)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_r eturn_code(SQLExceptionGenerator.java:448)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2 (DB2PreparedStatement.java:1247)
at COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute( DB2PreparedStatement.java:2389)
at GetBlob.storeOutputData(GetBlob.java:226)
at GetBlob.main(GetBlob.java:255)
________________________________________________

************SOURCE *********

DB2CallableStatement cs = (DB2CallableStatement) connection.prepareCall("{call MUS.SP_StoreOutputData(?,?,?,?,?,?)}");

cs.setInt(1, 1)
cs.setInt(2, 2);

InputStream is = new ByteArrayInputStream(data.toString().getBytes());
cs.setBinaryStream(3, is, is.available());

.............
StoredProc takes (int, int, Blob, ....)