Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes Escaping special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Escaping special characters" Watch "Escaping special characters" New topic

Escaping special characters

Gopi Chand Maddula
Ranch Hand

Joined: May 11, 2010
Posts: 40

Hi JavaRanch,

I had a problem inserting my customer details in database. I have to insert customer into database as a column.
but i am facing a problem facing some values(for example: Queen's Court.),
Here my problem is inserting this value into database is not possible which should be done as it is.

Can any one please suggest me to overcome this problem in my java code.

Thanks in Advance...!
Raj S Kumar
Ranch Hand

Joined: Aug 06, 2006
Posts: 48
Hi Gopi,
Please try this issue in the JDBC forum. You could get answers from there as it is specific to JDBC.

Raj S Kumar
Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

Moving there.

How To Ask Questions How To Answer Questions
Gopi Chand Maddula
Ranch Hand

Joined: May 11, 2010
Posts: 40

Hi Raj,

Thanks for Reply,

But i need to escape the bad characters in string before inserting into database.
so that i can use that code for verifying some other conditions also....!

Is it possible....?
David Newton

Joined: Sep 29, 2008
Posts: 12617

SQL escape it, or use a prepared statement?
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

I recomment using a prepared statement unless you have a really good reason not to. It takes care of escaping such values for you when you call stmt.setString().

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Escaping special characters
It's not a secret anymore!