• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

Escaping charaters in insert via JDBC driver

PHP have a function called addslashes() that escapes characters such as backslash, single quote and double quote. Are there an equivalent method in Java.

I was told to look at PreparedStatement but the JDBC driver I'm using doesn't implement that method.

The main problem is that sentences are split due to the escape characters.

Does java have an addslashes equivalent or is there any other way of doing this?

Thanks
Joachim
0
joachimc
Asked:
joachimc
1 Solution
 
aozarovCommented:
I don't think Java has special JDBC escape method.
You can use String.replace or String.replaceAll.
e.g
bsh % "hello\"world".replace("\"","\"\"");
<hello""world>
0
 
joachimcAuthor Commented:
Hmm ok..

Not exactly what I am hoping for. Anyone else that has heard anything?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now