I have problem with inserting very large data into DB2 in java using stored procedures.
I know only one way to do it now, with using method: CallableStatement.setObject(<index>, byte[], Types.BLOB)
and it could looks like this:
Code:
CallableStatement callableStatement = connection.prepareCall("{call TEST_BLOB(?)}");
FileInputStream fisb = new FileInputStream("someLargeFile.jpg");
byte[] buforb = new byte[fisb.available()];
fisb.read(buforb,0,buforb.length);
callableStatement.setObject(1,buforb,Types.BLOB);
callableStatement.execute();
...
where "TEST_BLOB" is stored procedure which inserting BLOB into some table.
The problem is when the file is really very large and it cannot be loaded into memory, into byte[] array. Is there any way to write data into BLOB field in not so big "packs"? Can I transfer InputStream (not byte[] array) into CallableStatement?
Thanks
Kuba Królikowski