Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to download a zip file from database?

 
vidhi sanghavi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a zip file physically stored in database.
I need to read the file from database and download it .
When I tried to get the data from database using getAsciiStream and wrote it using FileWriter zip file got created but unzipping the file gives error..
I also tried unzipping the zip file but that also gave an exception

Please help!!!

Thanks in Advance

Vidhi
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use rs.getBinaryStream for reading BLOB columns.
 
vidhi sanghavi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I forgot to mention the data is stored as CLOB in database.

Thanks
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is it a CLOB and not a BLOB? It's not text, is it?
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vidhi

Could you provide the full stack trace of the exception you are getting?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18012
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you attempt to present a ZIP file from a JSF view, JSF will corrupt it. Same for PDF's, Word documents, Excel spreadsheets and any other non-HTML file format. JSF is expecting to output HTML and only HTML.

Use an ordinary servlet to present the ZIP file for download. JSF is not greedy, it won't mind.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic