4

Possible Duplicate:
Cannot use a Like query in a JDBC prepared statement?

Is it possible to prepare a SQL statement like this:

SELECT COUNT(?) FROM TABLE WHERE COLUMUN_1 LIKE '%?%'

and in Java,

preparedStmt.setString(1, "COLUMN_2");
preparedStmt.setString(2, "FORD");
Community
  • 1
  • 1
user726579
  • 471
  • 6
  • 12
  • 3
    The answer to http://stackoverflow.com/questions/2857164/cannot-use-a-like-query-in-a-jdbc-prepared-statement answers this question perfectly. – Serdalis Nov 15 '12 at 22:28

1 Answers1

2

Nope. As a general rule, you can only use placeholders for values, not identifiers like table and column names.

Mark Reed
  • 91,912
  • 16
  • 138
  • 175