Search code examples
javaoracledb2clobsqlj

CLOB value too large to insert into DB2 table


I have a java.sql.Clob object which I populate from an Oracle query and then I have to insert this field at DB2 table (also a Clob column). So, at my sqlj class I created a java.sql.Clob type and set the value with the result from Oracle select (also a java.sql.Clob). The length of the Clob I'm trying to insert has about 2,5Mb or dbms_lob.getlength returns 2500012.

When the SQLJ executes, it throws an Exception:

COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2] SQL0433N Value "" is too long. SQLSTATE=22001

The DB2 version I'm using is Database server = DB2 OS/390 8.1.0

The Oracle version is Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit

Do you have any idea why this error is thrown? I was looking for the IBM documentation and it is suppose to use java.sql.Clob object to insert into DB2 clob column...

"Input parameters for CLOB columns For IN parameters for CLOB columns, or INOUT parameters that are used for input to CLOB columns, you can use one of the following techniques: Use a java.sql.Clob input variable, which is an exact match for a CLOB column: cstmt.setClob(parmIndex, clobData); ..."


Solution

  • Increase the size of the CLOB column in the database. Check this link for maximum clob column size

    http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/admin/r0001029.htm