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 > Storing Zip file in BLOB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-19-09, 14:52
rempre rempre is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
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.
Reply With Quote
  #2 (permalink)  
Old 08-19-09, 16:17
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
  #3 (permalink)  
Old 08-19-09, 17:51
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
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
Reply With Quote
  #4 (permalink)  
Old 08-19-09, 19:56
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
CLOB is not good for binary data, which is what a zip file contains.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #5 (permalink)  
Old 08-19-09, 23:04
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #6 (permalink)  
Old 08-20-09, 13:16
rempre rempre is offline
Registered User
 
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.
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