aspose file tools*
The moose likes JDBC and the fly likes Save and retrieve image in derby database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Save and retrieve image in derby database" Watch "Save and retrieve image in derby database" New topic
Author

Save and retrieve image in derby database

Madhuri Abhi
Greenhorn

Joined: Jun 29, 2011
Posts: 11
I want to save an image in derby database and retrieve it. Please help me out in this. Its very urgent
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

Please EaseUp. There's no such thing as urgent around here.

Did you declare the column as a BLOB, or the Derby equivalent? You can then use PreparedStatement and its setBytes, setBlob or setBinaryStream methods. Retrieving is done using ResultSet's getBytes, getBlob or getBinaryStream methods.

I'll move this thread to our JDBC forum. And welcome to the Ranch!


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Madhuri Abhi
Greenhorn

Joined: Jun 29, 2011
Posts: 11
I have saved the image in database but not able to retrieve it by converting it from hex(thats how its stored in database) to image.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

So all you need to do is convert the hex into a byte[], then convert the byte[] into an image. For the first you should use our search; I can clearly remember a discussion about it in Java in General. For the second you can use ImageIO.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Save and retrieve image in derby database