Re: PreparedStatement.setString with null

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: PreparedStatement.setString with null
Дата
Msg-id 415BE131.8080203@opencloud.com
обсуждение исходный текст
Ответ на PreparedStatement.setString with null  (Tim Penhey <tim@penhey.net>)
Список pgsql-jdbc
Tim Penhey wrote:
> What is this supposed to do?
>
>    PreparedStatement stat = connection.prepareStatement("update table1
> set col1 = ?");
>    stat.setString(1, null);
>
> Will this make a null value in the database or an empty string?  Do we
> have to use the setNull(1, Types.VARCHAR) in order to get a null value
> entered?

The postgresql JDBC driver treats setString(x, null) identically to
setNull(x, Types.VARCHAR). I don't know how portable this behaviour is;
the javadoc is silent on how this case should be handled. You're
probably better off using setNull() explicitly.

-O

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

Предыдущее
От: Roland Walter
Дата:
Сообщение: Re: PreparedStatement.setString with null
Следующее
От: "Katsaros Kwn/nos"
Дата:
Сообщение: Java app and SPI functions