PreparedStatement parameters question

Поиск
Список
Период
Сортировка
От Dr. Evil
Тема PreparedStatement parameters question
Дата
Msg-id 20011020223405.1875.qmail@sidereal.kz
обсуждение исходный текст
Ответы Re: PreparedStatement parameters question
Список pgsql-jdbc
I have a table like this:

CREATE TABLE foo { number INT, name VARCHAR(100), email VARCHAR(100));

and I am trying to do this with a prepared statement:

PreparedStatement st = db.prepareStatement("UPDATE foo SET ? = '?' " +
          "WHERE number = ?");

Whenever I use this I get a "Parameter index out of range" error.

I am assuming that what this means is that I can't use a ? as a column
name, but it can only be used as a parameter.  Am I correct in this?

The main reason I want to use PreparedStatement in this case is for
safety.  Should I basically do it like this:

PreparedStatement st = db.prepareStatement("UPDATE foo SET " + colname
          + "= '?' WHERE number = ?");

Is that the only way to do this?

Thanks

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Dave Cramer"
Дата:
Сообщение: Re: [PATCHES] Ant configuration
Следующее
От: "Dr. Evil"
Дата:
Сообщение: Does PG's JDBC support prepared statements at all?