How to parametrize fields of a SELECT statement?

倖福魔咒の 提交于 2019-12-11 06:37:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!