Scorpion
Scorpion

Reputation: 587

Issue with Prepared Statement when using "?"

Well, my question concisely is "When I wrote the ? in place of the table name it gave no action " like here, suppose I have..

String full = "update ? set name = ? where id = ?";

but when I remove the first ? and type the table name "Everything goes perfect" ... Any suggestions ?

Upvotes: 0

Views: 61

Answers (2)

rgettman
rgettman

Reputation: 178333

In JDBC, the ? placeholder stands for a value, and it cannot stand for an identifier such as a table name. It can be used where a literal value can be used. You'll notice you can't have the ? where a column name is expected either.

Upvotes: 5

David Ehrmann
David Ehrmann

Reputation: 7576

You can't use placeholders for table names.

Upvotes: 0

Related Questions