• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Save and retrieve image in derby database

 
Madhuri Abhi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to save an image in derby database and retrieve it. Please help me out in this. Its very urgent
 
Rob Spoor
Sheriff
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Madhuri Abhi
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20545
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic