Monday, January 24, 2011

java.sql.SQLException: Data size bigger than max size for this type

Hi All,

Last week i was facing an issue on inserting Blob data in Oracle 10g database. I tested my application on Jboss container and locally my application was running fine, the real problem i faced when i deployed it on Oc4J container.

I got this error ::: java.sql.SQLException: Data size bigger than max size for this type

I tried everything, even i upgraded my jdbc driver but the problem was still there.


Here is my problem code ::



CallableStatement cstmt =
dbConnection.prepareCall("{

call product_image(?,?,?)}");


cstmt.setInt(1, id);
cstmt.setBinaryStream(2,file.getInputStream(), (int) file.getFileSize());
cstmt.setString(3, companyCode);

cstmt.registerOutParameter(1, oracle.jdbc.driver.OracleTypes.INTEGER);

cstmt.execute();
int returnValue=cstmt.getInt(1);

I am using Jdk 1.4 and even my OC4J server is having jdk 1.4

 I temporarily resolved the issue using simple update statements using prepared statement and inserted blob in  my DB, but i wanted that via a procedure.

 Later, i tried below code and it worked fine ::


String sql = "{call TEST_INSERT_USER_REG(?)}";
cstmt = conn.prepareCall(sql);
cstmt.setBytes(1, Your BLOB data in Bytes);
cstmt.close();
 


Cheers,

Ujjwal Soni








No comments: