This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert image to blob type

 
addrian brilianda
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to insert image to oracle database with JPA and EJB 3... give me a simple code for example
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65338
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose an appropriate forum for your posts. This forum is for questions on Servlets, not JDBC. For more information, please click this link ⇒ CarefullyChooseOneForum.

This post has been moved to a more appropriate forum.

Also read NotACodeMill. You need to write your own code.
 
Palak Mathur
Ranch Hand
Posts: 342
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what exactly you want, but I think you may want to use following (I am not going to help you with the sample code), but with general idea:-

1. Create a File object with the image file that you want to store.
2. Convert the file object to InputStream.
3. Using setBinaryStream insert the InputStream created in step 2, store the image in db.
 
Santiago Tovar
Greenhorn
Posts: 11
Java Spring Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Just put the image in a byte[] (to do this use what Palak Mathur said) and set the column type: Lob (Lob annotation).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic