Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes How to retreive a blob.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to retreive a blob...." Watch "How to retreive a blob...." New topic
Author

How to retreive a blob....

Bharat Agarwal
Greenhorn

Joined: Jun 16, 2001
Posts: 21
Hi all,
I am trying to retreive a blob from the oracle 8.1.6.0.0 using jdk1.3. I tried most of the method's as per the API but could not get any result.
blob = (java.sql.Blob) rs.getObject(3);
InputStream in = blob.getBinaryStream();
byte[] b_blob = new byte[blob.length()];
b_blob = in.getBytes(1, blob.length());
// length = blob.length();
// txtfield.append("Length of blob : " + length);
Is there any other way out to retreive the blob. I have tried get Blob method as well. Moreover, I am not able to print the length of the blob as well.
I was able to insert the blob in the oracle database but could not check it exactly what is going in. As I tried to import the table in MS Access, it give me long binary data(AS MS access does not have objects). Can any one please, help me in how to check what is inserted in the table and also how to retreive the blob....Sample code is most welcome.
tia.........
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

here is a sample: http://otn.oracle.com/sample_code/tech/java/sqlj_jdbc/files/advanced/advanced.htm
click on the
LOB Datatype
JDBC: Source

about the length issue: http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_16_
this may be relevant or not..
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retreive a blob....