This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Inserting image into the oracle database  RSS feed

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I insert an array of bytes obtained from an image into an Oracle BLOB type column using JDBC 2.0 type 4 driver?
Thanks
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the JDBC Forum
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have already extracted the byte array for the image, then try

You can also look at setBlob() method of the xxxxxxxxStatement object you use.
 
Anirban dutta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried out the method of the setBlob. But the problem is how to get the reference of the Blob interface. I couldn't find any code which returns the Blob's reference.
So I tried it in a different way:
I inserted a empty image into the database by empty_blob() function of SQL. Then I used the setBytes of the blob interface to set the image bytes in it. But it gave an runtime exception:
java.lang.AbstractMethodError.
What could be the problem. Please help me in solving it.
 
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this post: http://www.coderanch.com/t/79988/Oracle-OAS/Inserting-BLOB
Rene
 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is how I have done
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!