I am reading file from ResultSet and it's required to save file into Oracle Database.
...
ResultSet rs = ...
java.sql.Blob myfile = rs.getBlob("field")
java.io.OutputStream os = ((oracle.sql.BLOB) myfile).getBinaryOutputStream();
I get get this error message
java.lang.ClassCastException
Any one have solution to this? Thanks!
I have found the solution. I'd like to share with those who has this problem.
The code to get outputstream from oracle blob is:
java.io.OutputStream os = ((oracle.sql.BLOB) myBlob).setBinaryStream(1L);
setBinaryStream() is actually returning java.io.OutputStream object
java.sql.Blob
is an interface. Presumably the implementation returned in your ResultSet
is a different implementation to oracle.sql.BLOB
?
What does myfile.getClass()
return?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With