• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem when readin blob

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am inserting a blob in my Oracle DB.I first insert an empty_blob() and then update this same empty_blob with a pdf file.This is how i update it:

I am then trying to read this blob with the following code:


the problem is that when i am reading the blob, the blob object is coming as null and hence i am getting a null pointer exception. Can anybody tell me where i am going wrong?
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried the getBlob method of java.sql.ResultSet, or tried avoiding java.sql.Blob and using getBinaryStream or getBytes?
 
dnyan ginde
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Yes i have tried using getBinaryStream() and getBytes() methods but the InputStream and the byte[] is coming as null. When i am inserting the blob into the DB i am getting no exception and that makes me feel asthough the blob is getting inserted properly. But then again when i am retrieving it why is it coming as null. Any suggestions?
 
dnyan ginde
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, after struggling with the Blob for quite a long time ive finally inserted and retrieved the blob. Just for your information Oracle just accepts Blob/Clob instances created via its own proprietary BLOB/CLOB API, and additionally doesn't accept large streams for PreparedStatement's corresponding setter methods. So anybody out there facing problems with blob or clob please use Oracle API's if your database is Oracle.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic