This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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
Posts: 65658
129
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).
 
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!