If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Inserting very large data with JDBC

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-06-04, 15:38
kubak kubak is offline
Registered User
 
Join Date: May 2004
Posts: 4
Inserting very large data with JDBC

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
Reply With Quote
  #2 (permalink)  
Old 05-06-04, 17:31
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
How about CallableStatement.setBinaryStream()?
Reply With Quote
  #3 (permalink)  
Old 05-07-04, 09:56
kubak kubak is offline
Registered User
 
Join Date: May 2004
Posts: 4
sure

Yes, sure, setBinaryStream works and this is the solution. Thanx.

Kuba
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On