This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need to read the blob and convert it into a file

 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I need to convert the oracle blob into a file and probably show it on my JSP or html page. blob could be of a jpg, gif, pdf, doc, txt, bmp, etc.

what i am doing is uploading a file (using apache DiskFileUpload), then gettin bytes (using fileItem.get()). now i need to store it in oracle as a blob, upon retreiving i need to convert it back into a file.

any suggestions...
thanx
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you know how to use JDBC to connect to Oracle. Just use PreparedStatement.setBytes() to write the bytes to a Blob. ResultSet.getBytes() will get them back.

Jules
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx buddy. but how can we get the blob and convert it to the same file again??

thanx
 
Julian Kennedy
Ranch Hand
Posts: 823
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.FileOutputStream.write(byte[] bytes)

Jules
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic