File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes need to read the blob and convert it into a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "need to read the blob and convert it into a file" Watch "need to read the blob and convert it into a file" New topic
Author

need to read the blob and convert it into a file

Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
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

Joined: Aug 02, 2004
Posts: 823
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

Joined: Aug 15, 2004
Posts: 2874
thanx buddy. but how can we get the blob and convert it to the same file again??

thanx
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
java.io.FileOutputStream.write(byte[] bytes)

Jules
 
wood burning stoves
 
subject: need to read the blob and convert it into a file
 
Similar Threads
jpg to BLOB and BLOB to JPG
How to convert FormFile into BLOB object?
converting Blob to a String for calling POST
Parsing BLOB datatype
need to convert oracle blob into a file