wood burning stoves 2.0*
The moose likes JDBC and the fly likes Escaping special characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Escaping special characters" Watch "Escaping special characters" New topic
Author

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
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Moving there.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: May 26, 2003
Posts: 30136
    
150

Gopi,
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().


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Escaping special characters
 
Similar Threads
Auto increment key in Hibernate
not able to insert values in ms access database
Arabic Digits Encoding
Problem facing with executebatch function
two actions from one page