Solved

trim() ???

Posted on 2002-03-04
5
304 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Coldfusion 10 - JSP File Not Found - 404 Error 5 98
grep code 4 199
oracle fusion vs MQ 2 122
Unhandled exception type Exception 18 42
IT certifications are a concrete representation of continual learning on the part of the candidate.  Continual learning is necessary for the long term success of an IT professional, but are IT certifications the right path for you?
Learn how to PXE Boot both BIOS & UEFI machines with DHCP Policies and Custom Vendor Classes
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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