Solved

trim() ???

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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
session bean client machine 9 66
love6 challenge java 31 133
difference between sorce folder and folder in eclipise 3 45
running on tomcat not jboss eap 7.0 3 33
While it may be true that the internet is a place of possibilities, it is also a hostile environment lurking with many dangers. By clicking on the wrong link, trusting the wrong person or using a weak password, you are virtually inviting hackers to …
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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