File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate BLOB retrieving

 
Shaik Mohammed Arif
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
i am working with BLOB and and i am getting a null pointer exception when i tried to retrieve a Blob from database..

Here is my code..

try {
textfile = document.getBinaryBlob();
InputStream is = document.getBinaryBlob().getBinaryStream();
while (is.read(buffer) > 0) {
outStream.write(buffer);
}

outStream.close();

Please help me in this regards..
 
Campbell Ritchie
Sheriff
Pie
Posts: 47271
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NullPointerExceptions are hardly advanced topics!

You are calling document.getBinaryBlob() twice; your 2nd call should read textfile.getBinaryStream();

Either "document" or "outStream" is null in that block. You should be able to work out which from the stack trace which gives line numbers.

And in future, please provide more details; it would have been much easier to answer with copy of the stack trace. And please use the code button when you quote code like that; it makes it much easier to read.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic