How do I escape a literal question mark ('?') in a JDBC prepared statement

前端 未结 5 1813
醉酒成梦
醉酒成梦 2021-02-19 10:56

I\'d like to create a JDBC PreparedStatement like:

SELECT URL,LOCATE ( \'?\', URL ) pos FROM Links WHERE pageId=? ORDER BY pos ASC

Where the 1s

5条回答
  •  礼貌的吻别
    2021-02-19 11:36

    If it doesn't work with your JDBC driver you could bind it as a String ?,

    ps.setString(1, "?");
    

提交回复
热议问题