The character ?
is used as placeholder in JDBC but is also a valid literal in the pattern
clause (e.g., for non-greedy matching). Per default, the Oracle JDBC driver treats each ?
as bind parameter. To use ?
as literal in the pattern
clause, the Oracle JDBC driver supports two methods:
Statement.setEscapeProcessing(false)
This is a standard JDBC feature that disables any client side interpretation of the SQL string. It doesn’t work for PreparedStatements
and thus disallows the use of bind variables.
{\?\}
The Oracle JDBC driver support a proprietary escape syntax for the question mark: {\?\}
. This character sequence can be used in the pattern
clause instead of a question mark. This method works for PreparedStatement
s.
The essence of SQL tuning in 200 pages
Buy on Amazon
(paperback only)
Paperback and PDF also available at Markus’ store.
Markus offers SQL training and consulting for developers working at companies of any size.
Learn more »