Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Special characer in Database + problem in trimming it with trim()

 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am having a Database where one column contain special Character .

i want to trim this special character as i am interested in the value excluding this special character.

i used trim() method of java but it did not work and searched a lot but did not get any answer.

can anybody please tell me how to solve this issue as i stuck for a long time doing this.

Thanks
Raza!
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
trim() removes whitespace characters. Is the special character a whitespace character? Can you give us an example of the column contents you are dealing with?
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i dont know but i am unable to trim it with trim()

it is something like pi sign in mathematics.

please help me.

Thanks.
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what happens when you try something like:
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i am fetching the data from database which is having this special character.

but when i trim it i dont get the data excluded from that special character.

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raza Mohd wrote:Actually i am fetching the data from database which is having this special character.

but when i trim it i dont get the data excluded from that special character.



right. don't use trim(). trim only gets rid of whitespace. a symbol that looks like pi does not qualify as whitespace.
what happens when you use the replaceAll() example against the result of the fetch from the database?

also, can you output the string you are getting from the database?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic