X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BE257563A1 for ; Mon, 7 Mar 2005 20:04:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90347-01 for ; Mon, 7 Mar 2005 20:04:49 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id A715955056 for ; Mon, 7 Mar 2005 20:04:45 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1D8OT3-0004n1-00; Tue, 08 Mar 2005 09:04:41 +1300 Message-ID: <422CB3D7.50000@opencloud.com> Date: Tue, 08 Mar 2005 09:04:39 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Mican Bican Cc: pgsql-jdbc@postgresql.org Subject: Re: java.sql.date insert as null References: <422CA65C.7050303@gmail.com> In-Reply-To: <422CA65C.7050303@gmail.com> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/56 X-Sequence-Number: 12449 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