Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id DD9329FB5AC for ; Mon, 30 Apr 2007 22:53:22 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 78551-01 for ; Mon, 30 Apr 2007 22:53:14 -0300 (ADT) X-Greylist: delayed 00:18:06.998536 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 771FF9FB6E7 for ; Mon, 30 Apr 2007 22:53:15 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from hydra.ephibian.com (hydra.ephibian.com [209.150.90.87]) by svr4.postgresql.org (Postfix) with ESMTP id B13E55AF032 for ; Tue, 1 May 2007 01:35:06 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by hydra.ephibian.com (Postfix) with ESMTP id 3A89E10CA12 for ; Mon, 30 Apr 2007 18:35:04 -0700 (MST) Received: from hydra.ephibian.com ([127.0.0.1]) by localhost (hydra.ephibian.com [127.0.0.1]) (amavisd-maia, port 10024) with ESMTP id 22893-02 for ; Mon, 30 Apr 2007 18:35:04 -0700 (MST) Received: from [10.1.1.108] (velma.ephibian.com [206.169.96.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hydra.ephibian.com (Postfix) with ESMTP id 038DEA8C17 for ; Mon, 30 Apr 2007 18:35:03 -0700 (MST) Message-ID: <46369940.1030801@ephibian.com> Date: Mon, 30 Apr 2007 18:34:56 -0700 From: Chris Stuhr User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Null bind variable in where clause Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 200704/141 X-Sequence-Number: 16990 It looks like you can not use a bind variable when trying to match null in a where clause. Is there any way to get the desired effect without having to remove the bind variable and rewrite the query to "WHERE b IS null"? import java.sql.*; public class a { public static void main(String args[]) throws Exception { String sql = "CREATE TABLE t(a int, b int)"; Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection( "jdbc:postgresql://10.20.1.70:5432/firm", "gaiam", ""); try { Statement stmt = conn.createStatement(); stmt.executeUpdate(sql); sql = "INSERT INTO t(a,b) VALUES (3,null)"; stmt.executeUpdate(sql); stmt.close(); } catch (SQLException sqle) { sqle.printStackTrace(); } sql = "UPDATE t SET a = ? WHERE b = ?"; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setInt(1, 4); pstmt.setObject(2, null); int x = pstmt.executeUpdate(); System.out.println(x); pstmt.close(); Statement stmt = conn.createStatement(); stmt.executeUpdate("DROP TABLE t"); stmt.close(); conn.close(); } } Will print 0 instead of 1 -Chris