Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    4

    Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    How about CallableStatement.setBinaryStream()?

  3. #3
    Join Date
    May 2004
    Posts
    4

    sure

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

    Kuba

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •