问题
Is there a way to parametrize fields of a SELECT statement using PreparedStatement or other utilities?
I mean something like:
SELECT ?, ? FROM MY_TABLE WHERE ? = ?
回答1:
No, JDBC does not let you do that. The idea behind parameters is to speed up execution and avoid SQL interjections; parameterizing the columns that you are selecting does not help either of these two goals.
回答2:
Try with the following
http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html
来源:https://stackoverflow.com/questions/10449972/how-to-parametrize-fields-of-a-select-statement