X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 72DCE9DCDCE for ; Wed, 1 Feb 2006 13:15:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88754-06 for ; Wed, 1 Feb 2006 13:15:34 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mail.logix-tt.com (serval.logix-tt.com [213.239.221.42]) by postgresql.org (Postfix) with ESMTP id E96579DCDCF for ; Wed, 1 Feb 2006 13:15:33 -0400 (AST) Received: from kingfisher.intern.logix-tt.com (Mc594.m.pppool.de [89.49.197.148]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.logix-tt.com (Postfix) with ESMTP id 734D424400F; Wed, 1 Feb 2006 18:15:26 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) by kingfisher.intern.logix-tt.com (Postfix) with ESMTP id 76ABE181C2099; Wed, 1 Feb 2006 18:15:25 +0100 (CET) Message-ID: <43E0ECAD.3060609@logix-tt.com> Date: Wed, 01 Feb 2006 18:15:25 +0100 From: Markus Schaber Organization: Logical Tracking and Tracing International AG, Switzerland User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: en-us, en MIME-Version: 1.0 To: =?ISO-8859-2?Q?Papp_M=E1rton?= Cc: pgsql-jdbc@postgresql.org Subject: Re: timestamp parameter is null References: <43E0DFE1.9020200@assixo.com> In-Reply-To: <43E0DFE1.9020200@assixo.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.128 required=5 tests=[AWL=0.128] X-Spam-Score: 0.128 X-Spam-Level: X-Archive-Number: 200602/8 X-Sequence-Number: 14605 Hi, Papp, Papp Márton wrote: > I'm trying to execute a simple SQL query with JDBC and I get an > exception, which I don't understand why. Here's the code: > > public static void main(String[] args) throws Exception { > Class.forName("org.postgresql.Driver"); > Connection conn = > DriverManager.getConnection("jdbc:postgresql://localhost:5434/dbname", > "user", "pass"); > PreparedStatement stm = conn.prepareStatement("select * from > tablename where ? is not null"); > stm.setTimestamp(1, new Timestamp(new Date().getTime())); > stm.executeQuery(); > } Are you shure that your query is correct? This would return no rows if you set parameter 1 to null, and the whole table if you set your parameter to anything not-null. If you really want to do this, use "select * from tablename where ?::timestamp with time zone is not null" hth, schabi -- Markus Schaber | Logical Tracking&Tracing International AG Dipl. Inf. | Software Development GIS Fight against software patents in EU! www.ffii.org www.nosoftwarepatents.org