Re: PreparedStatements, LIKE and the % operator

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: PreparedStatements, LIKE and the % operator
Дата
Msg-id eq1ko7$v73$1@sea.gmane.org
обсуждение исходный текст
Ответ на PreparedStatements, LIKE and the % operator  ("j.random.programmer" <javadesigner@yahoo.com>)
Список pgsql-jdbc
j.random.programmer wrote on 03.02.2007 04:58:
> Hi:
>
> I am using postgres 8.2 with the 8.2.504 jdbc3 driver.
>
> I am getting data from a untrusted source. Hence a
> prepared
> statement. I also need a partial match.
>
> String query =  " select * from table_foo where bar =
> LIKE %?% "
> PreparedStatement ps = con.prepareStatement(query);
> ps.setString(1, "haha");

That should be:

String query = "select * from table_foo where bar like ?";
PreparedStatement ps = con.prepareStatement(query);
ps.setString(1, "%haha%");

Thomas

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

Предыдущее
От: "j.random.programmer"
Дата:
Сообщение: Re: PreparedStatements, LIKE and the % operator
Следующее
От: Barry Lind
Дата:
Сообщение: Re: PreparedStatements, LIKE and the % operator