wood burning stoves*
The moose likes Object Relational Mapping and the fly likes Hibernate BLOB retrieving Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate BLOB retrieving" Watch "Hibernate BLOB retrieving" New topic
Author

Hibernate BLOB retrieving

Shaik Mohammed Arif
Greenhorn

Joined: Aug 06, 2008
Posts: 7
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

Joined: Oct 13, 2005
Posts: 38057
    
  22
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate BLOB retrieving
 
Similar Threads
Saving Japanese Characters in Oracle Blob using Java program
how to convert byte[] to blob
OutOfMemoryExcepiton!
How to convert FormFile into BLOB object?
inserting data in to blob...