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 800A932A08D for ; Thu, 30 Sep 2004 11:35:04 +0100 (BST) 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 29345-04 for ; Thu, 30 Sep 2004 10:34:51 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id B3391329F48 for ; Thu, 30 Sep 2004 11:34:51 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1CCyGb-0006c3-00; Thu, 30 Sep 2004 22:34:29 +1200 Message-ID: <415BE131.8080203@opencloud.com> Date: Thu, 30 Sep 2004 22:34:25 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tim Penhey Cc: "pgsql-jdbc@postgresql.org" Subject: Re: PreparedStatement.setString with null References: <415BD807.6040103@penhey.net> In-Reply-To: <415BD807.6040103@penhey.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/211 X-Sequence-Number: 11101 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