File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Database escape char. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Database escape char." Watch "Database escape char." New topic
Author

Database escape char.

claude favre
Greenhorn

Joined: Jun 25, 2001
Posts: 5
Hello,
Is there a function in java similar to the php "stripslashes" function or do I have to parse the string myself before inserting a record to mysql?
Thank you.
claude
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

what does the "stripslash" function in PHP do?
If you are worried about special characters, then use the prepared statement because it deals with special characters internally.
Jamie
claude favre
Greenhorn

Joined: Jun 25, 2001
Posts: 5
It basically deal with special char in text such O'brien, it would in this example escape the apostrophe.
Claude
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Use a preparedStatement instead of a statement then. It handles the database special characters for you.
This works with prepared statement:

where as it throws a SQLException when using Statement:

SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'emp_fname = 'O'Brien''.

Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database escape char.
 
Similar Threads
Functions of fire wall
XSLT: How to show the Tag NAME?
How do i call my function in JSP
WA #1.....word association
Dynamically set the xsl:value-of select through a xsl:variable