is it possible to run this query
jdbcTemplate.update(
"UPDATE SOME_TABLE SET MY_NAME=?,MY_FILE=?" +
"WHERE MY_ID = ?",
new Object[] {
"TestME",null,ID
});
Note that there is no space between the 2nd ? and WHERE keyword.
I can add a space in between and make it run but we have such instance in many places so wanted to check if we can avoid code changes
2
Answers
No, it is not possible. The space is required to separate the parameter from the
WHERE
. Fix your code. It should be simple with a find and replace. Search for"WHERE
and replace with" WHERE
.Well, why don’t you test it?
My test in plain JDBC shows a valid statement. I’m using Groovy script with JDBC, but assume that the same behaviour will occure in jdbcTemplate. The SQL string is important.
the output is
And by the way SQL realy do not requires blank separators in each possition. This is also a valid statement.
Tested in
PostgreSQL 14.4