Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • 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
Posts: 20827
68
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
Posts: 20827
68
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!