• Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate BLOB retrieving

 
Shaik Mohammed Arif
Greenhorn
Posts: 7
  • 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
Marshal
Posts: 53191
124
  • 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.
 
my overalls have superpowers - they repel people who think fashion is important. 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!