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
Depending on the JDBC driver you are using you may be able to escape by adding another question mark e.g. if you're using PostgreSQL
https://jdbc.postgresql.org/documentation/head/statement.html
In JDBC, the question mark (
?
) is the placeholder for the positional parameters of a PreparedStatement. There are, however, a number of PostgreSQL operators that contain a question mark. To keep such question marks in a SQL statement from being interpreted as positional parameters, use two question marks (??
) as escape sequence. You can also use this escape sequence in a Statement, but that is not required. Specifically only in a Statement a single (?
) can be used as an operator.