how to get the content from BLOB datatype in java

HI Experts,

I have  a table in database for that table one of the column is of type BLOB.
this column contains some data. how to get the data from this column.
Can any one suggest how to do
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CPColinSenior Java ArchitectCommented:
Use ResultSet.getBlob() to get the Blob object and then call Blob.getBytes() or Blob.getBinaryStream() to get the bytes or an InputStream that you can read from to get the bytes.

You can also call getBinaryStream() on the ResultSet object directly.
srikoteshAuthor Commented:
i am not using result set

i am getting the value from the database
now i have to get the value

Object master = dao.getTableDetails();
if(master ! = null)
//here i have to get the value
byte[] data =(Blob) row[0];
//here i am getting class cast exception
srikoteshAuthor Commented:
Blob blobdata = (Blob) row[0];
byte[] data = blobdata.getBytes()

i have tried like this also
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

CPColinSenior Java ArchitectCommented:
What type of object is that row variable?
srikoteshAuthor Commented:
blob type
CPColinSenior Java ArchitectCommented:
It can't be a Blob. It's an array of some type, because you're trying to get the first element out of it.
srikoteshAuthor Commented:
yes I am retrieving two columns from the table.
first column is of type blob and second one is string.
iam retrieving from object array.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
can you post your full code listing.
srikoteshAuthor Commented:
from the database I am getting data type as byte array,not blob.
I have converted that byte array to blob then I converted blob to string.
CPColinSenior Java ArchitectCommented:
from the database I am getting data type as byte array,not blob.
I have converted that byte array to blob then I converted blob to string.

So you solved it yourself?
Which actually means your database (or JDBC driver) does not support JDBC Blob/Clob i.e incremental loading of big object from database as it is accessed.
srikoteshAuthor Commented:
Hi CPcolin,
Yes issue is resolved.

Hi gheist,
That might be the reason .
You worked around the issue, which is good result. If you do not intend to fix BLOB support in your DB you can close now.
srikoteshAuthor Commented:
i found solution my own with the help of CPcolin.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.