Solved

trim() ???

Posted on 2002-03-04
5
301 Views
Last Modified: 2010-04-01
My data is store as a blob type. When i retrieve it, it becomes a object. I tried to typecast it to a string but i get errors. WHy? Is there another way for me to trim the spaces away?
0
Comment
Question by:yan_er04
  • 2
5 Comments
 
LVL 19

Expert Comment

by:cheekycj
ID: 6838935
Isn't BLOB, Binary Large Object? so you wouln't be able to cast that to a string.


You can try retrieving it as a byte[] and then creating a string from that byte[].

have you tried trim in the query itself?
SELECT TRIM(BOTH ' ' FROM value) FROM test;
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 6841724
Did the above work?
0
 
LVL 3

Accepted Solution

by:
ibo earned 30 total points
ID: 6849617
try this snippet.. this works perfectly

                 BufferedInputStream bis = new BufferedInputStream(rsD.getBinaryStream("DATA"));
                    byte[] data = new byte[1024];
                    int byteCount;
                   
                    while ((byteCount = bis.read(data, 0, 1024)) > -1) {
                         out.write(new String(data), 0, byteCount);
                    }
                    bis.close();
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9552488
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

"Accept ibo's comment as answer."
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Kuldeepchaturvedi
EE Cleanup Volunteer
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Moving applications to the cloud or switching services to cloud-based ones, is a stressful job.  Here's how you can make it easier.
Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now