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
Thanks
LVL 2
srikoteshAsked:
Who is Participating?
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.
0
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
}
0
srikoteshAuthor Commented:
Blob blobdata = (Blob) row[0];
byte[] data = blobdata.getBytes()

i have tried like this also
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

CPColinSenior Java ArchitectCommented:
What type of object is that row variable?
0
srikoteshAuthor Commented:
blob type
0
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.
0
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.
0

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
gurpsbassiCommented:
can you post your full code listing.
0
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.
0
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?
0
gheistCommented:
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.
0
srikoteshAuthor Commented:
Hi CPcolin,
Yes issue is resolved.

Hi gheist,
That might be the reason .
0
gheistCommented:
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.
0
srikoteshAuthor Commented:
i found solution my own with the help of CPcolin.
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.