Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sql input statement, how can i input the character " ' "(apostrophe)?

807606Jun 22 2006 — edited Jun 8 2007
i know this this question had been answered, but i am having a hard time understanding it. so how can i make mysql db disregard the character ' ?
i think i need to use some escape statement or something. lets say the code is something like this:


try{
Statement stmt;
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
String url ="jdbc:mysql://localhost:3306/test";
Connection con = DriverManager.getConnection(url, "username", "password");
stmt = con.createStatement();
stmt.executeUpdate("UPDATE smbtable SET points = '"+newgender+"' where celNum = '"+celno+"'");
con.close();
}
catch( Exception e ) {
e.printStackTrace();
}
and the variable celno has a string like this "mark's cell number"... how so i make mysql treat this as one whole string despite the ' (apostrophe) sign?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 6 2007
Added on Jun 22 2006
11 comments
346 views