Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    2

    Unanswered: Storing Zip file in BLOB

    Hi all,

    I need to store a zip file in a BLOB column of a DB2 table. I am able to store the zip file but when I retrieve the file I get an exception "invalid distance code". We use Java to read and write data from DB2. I tried using Deflater as well as ZipInputStream/ZipOutputStream, both failed.

    Can someone suggest me a good way to store/retreive a zip file in a BLOB column of DB2?

    Thanks in advance.

    Regards,
    Prem.

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    A BLOB is just a chunk of binary data. There is nothing special about it and you can store/retrieve whatever you want in it.

    Now, the exception description you cited is not a DB2 error message. So it would be good if you tell us exactly the error DB2 is giving you (if there is any). And also don't forget to mention the DB2 version and platform you are using.

    My guess is that you have a problem in your application. So you should narrow down the code as much as possible, then post the result here so that we know how your code deals with DB2.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  3. #3
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963
    Try to use CLOB, instead of BLOB....

    You have to remember, when you save file, about the structure of the file, which is usually consist the file information....


    Lenny

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    CLOB is not good for binary data, which is what a zip file contains.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  5. #5
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    Quote Originally Posted by stolze
    CLOB is not good for binary data, which is what a zip file contains.
    That is because if your client has a different code page from your server, DB2 may do a code page conversion which would corrupt the binary file.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  6. #6
    Join Date
    Aug 2009
    Posts
    2
    Thanks for your replies. It was a mistake that I made in the client Java program. While reading from the BLOB, I first converted into a String and then passed on to the ZipInputStream. Now I directly passed the BLOB's stream to the ZipInputStream and it worked.

Posting Permissions

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