在线 发帖 发链 主题 评论 推荐 标签 作者 查搜 注册 登陆 关注
如果在数据库中有一个字符串保存成
java代码:
|"test"|
无论用jdbc怎样转义都报语法错误,我使用mysql4.1,mysql-jdbc-connector-3.0.
我的写法:
java代码:
ResultSet rs=stm.executeQuery("select * from a where name='\"test \"' s");
报错:
java代码:
Exception in thread "main" java.sql.SQLException: Syntax error or access violati
on message from server: "You have an error in your SQL syntax; check the manual
that corresponds to your MySQL server version for the right syntax to use near '
s' at line 1"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
at com.mysql.jdbc.MysqlIO.sqlQuery(MysqlIO.java:1224)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2244)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2192)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1163)
at lyo.hotmail.test.Test.main(Test.java:48)
使用单引号转义也没用!难道数据库中的 双引号字符串没办法查出来?
--转自