Caveat: I am not an expert in this area, or any area for that matter.  ;-)

It sounds like you really need to "create" a right?
...and then "fill it in?"  After some poking around, it looks like has a static method to create a new empty temporary

Try this:
-----8<---------- cut here ----------8<----------------
tokenBlob =;      // new Blob
OutputStream os = tokenBlob.getOutputStream();  // get stream to fill Blob
os.write(rs.getBytes("TokenUsedToUniquelyIdentifyRecord"));  // fill Blob
set(58, TokenBlob);



  ___   _           Blair Wyman                  IBM Rochester
 ( /_)  /  _  ' _   (507)253-2891            blairw@xxxxxxxxxx
__/__)_/_<_/_/_/_'  Opinions expressed may not be those of IBM

             Sent by:                                                   To 
             java400-l-bounces         java400-l@xxxxxxxxxxxx              
             11/27/2006 03:34          Re: UDTF returning Binary column to 
             PM                        iSeries                             
             Please respond to                                             
             Java Programming                                              
             on and around the                                             
              iSeries / AS400                                              

Thanks for the reply.

Have any ideas then how to convert or cast a byte[] to a Blob?
I've tried multiple ways but so far no luck and I don't think I want to go
from byte array to string to Blob.

Any ideas would be appreciated.

Thank You

Here's a snippet of my code:

import java.sql.*;
import java.math.BigDecimal;

  public void history(

    // input parameter(s)

    String              parmWhere,

    // output columns

        String          Transactioncode,
        String          OrderNumber,
        String          ItemNumber,
        String          Warehouse,
        Blob            TokenBlob)      // Have tried String

  throws Exception {

        byte [] TokenUsedToUniquelyIdentifyRecord;

String sql="SELECT " +
          "Transactioncode, " +
          "OrderNumber, " +
          "ItemNumber, " +
          "Warehouse, " +
          "TokenUsedToUniquelyIdentifyRecord, " +
  "FROM Inventory.dbo.Inventory_History " +
  (parmWhere.equals("")?"":"WHERE " + parmWhere);

// Read the SQL Server "binary" column as a byte array in Java then
convert or cast it to a DB2 Blob
// Type mismatch: Cannot convert from byte[] to a Blob
TokenBlob = rs.getBytes("TokenUsedToUniquelyIdentifyRecord");
 set(58, TokenBlob);

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.