[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • 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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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