From: Oliver Jowett <oliver@opencloud.com>
To: Mican Bican <mican58@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: java.sql.date insert as null
Date: Tue, 08 Mar 2005 09:04:39 +1300
Message-ID: <422CB3D7.50000@opencloud.com> (raw)
In-Reply-To: <422CA65C.7050303@gmail.com>
References: <422CA65C.7050303@gmail.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oliver@opencloud.com, mican58@gmail.com
Subject: Re: java.sql.date insert as null
In-Reply-To: <422CB3D7.50000@opencloud.com>
References: <422CA65C.7050303@gmail.com> <422CB3D7.50000@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox