Discussion Locked
0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I am working on a system the will be needing to make database calls using last name as a search parameter. I have been told that it is not possible to handle a ' in a name reliably (like O'Sullivan.) Can someone give me coding examples that will work in Java and Javascript? I have done this in other environments by using two ', to indicate that the ' should be handled as a character and not a delimiter.
7 replies
by dklippert
You could use ´ (?)instead of apostrophe (').
by oneilldavidj
The question was auto-closed by TechRepublic
by jay eckles
You could also use \ as an escape character in Java and Javascript.
//Java example:
String str = new String( "O\'Sullivan" ) ;
//Javascript example:
var str = 'O\'Sullivan' ;
Your DBMS may also require you to use a specific escape character when performing transactions like insert or update:
update names_tbl set last_name='O\'Sullivan' where ssn='123-45-6789'
Good luck.
Jay
by oneilldavidj
The question was auto-closed by TechRepublic
by nvjain73
I agree to what is given in Answer 2 by Jay except that for saving into the database you should use the PreparedStatment class. This class will be able to handle the ' in the strings that are passed to the query.
by oneilldavidj
The question was auto-closed by TechRepublic
by oneilldavidj
This question was auto closed due to inactivity
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending
Discussion Locked
What Makes a Business Website Effective in 2026
2 helpful
10 replies
1 helpful
3 replies
Question
Windows and macOS computers becoming slow or unstable after updates - what should I check first
0 helpful
1 reply
Question Unanswered
Best Way to Make Long WordPress Location Guides Mobile Friendly
0 helpful
0 replies
Discussion
Optimizing WordPress widgets and DOM size
0 helpful
3 replies