Solved

trim() ???

Posted on 2002-03-04
5
306 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Justin
In light of the WannaCry ransomware attack that affected millions of Windows machines, you might wonder if your Mac needs protecting. Yes, it does and here is how to do it.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 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