davioooh
davioooh

Reputation: 24676

How to parametrize fields of a SELECT statement?

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 ? = ?

Upvotes: 1

Views: 170

Answers (2)

sarwar026
sarwar026

Reputation: 3821

Try with the following

http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html

Upvotes: 1

Sergey Kalinichenko
Sergey Kalinichenko

Reputation: 726599

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.

Upvotes: 1

Related Questions