Re: java.sql.date insert as null

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: java.sql.date insert as null
Дата
Msg-id 422CB3D7.50000@opencloud.com
обсуждение исходный текст
Ответ на java.sql.date insert as null  (Mican Bican <mican58@gmail.com>)
Список pgsql-jdbc
Mican Bican wrote:

> How can I store a java.sql.date as null in database. The problem is
> (pseudecode):

Real test code would be much better.

> ..insert into Customer (id..,date,...)
> values(...
> ...." ' "+in.getSqlDate()+" ' ".....
> ...)

If in.getSqlDate() returns null, this turns into:

   insert into Customer (...) values (... 'null' ...)

which is wrong -- the NULL should be unquoted.

I'd suggest using a java.sql.PreparedStatement and parameter
placeholders, then you don't need to worry about the details of "how do
I represent a date in the right format for this DB?"

-O

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

Предыдущее
От: Mican Bican
Дата:
Сообщение: Convert java.sql.Date to java.util.Date
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: postgre 7.3 / JSTL problem