JDBC escape processing and HSQLDB regular expression syntax

15 Views Asked by At

What's wrong with this HSQLDB syntax:

 REGEXP_REPLACE(Title, '([0-9]{4})$')

The regular expression is intended to remove 4 digits in parentheses at the end of a string. Thanks for taking a look.

I tried various escaping with no success. Apparently the curly braces are being intercepted by JDBC as an escape sequence of its own.

1

There are 1 best solutions below

0
fredt On BEST ANSWER

You can turn JDBC escape processing off.

Statement statement = connection.createStatement();
statement.setEscapedProcessing(false);
statement.executeQuery("select REGEXP_REPLACE(Title, '([0-9]{4})$') from mytable");

The statement.setEscapedProcessing(false) has no effect on a PreparedStatement.