• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Outputstream from oracle blob

 
Faraz Ahmad
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

i am using oracle10g and Weblogic 10(Java 5)

Follwing is the snippet of code :

ResultSet rSet;
.
.
.
.
.
Blob blob1 = rSet.getBlob(1);

oracle.sql.BLOB blob2 = (oracle.sql.BLOB)blob1;

OutputStream os = blob2.getBinaryOutputStream();


Here is the exception i m getting.

java.lang.ClassCastException: weblogic.jdbc.wrapper.Blob_oracle_sql_BLOB

at line typecasting blob1 to blob2.

Can anyone help me out?

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
377
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faraz,
Welcome to JavaRanch!

This code snippet is dangerous as it relies on a specific implementation



The ResultSet interface provides a method to get the binary stream directly. Why not just use that?
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What Jeanne said. If you follow her approach, you 'll get your data.

About your error.
Blob blob1 can't be casted into an oracle.sql.BLOB.
The returned BLOB you got from rSet.getBlob(1) is not convertible to oracle.sql.BLOB.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic