Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 501BC9FB874 for ; Fri, 13 Apr 2007 16:09:40 -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 27594-09 for ; Fri, 13 Apr 2007 16:09:35 -0300 (ADT) X-Greylist: delayed 00:21:45.186977 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 169669FBA18 for ; Fri, 13 Apr 2007 16:09:36 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from list.xcski.com (list.xcski.com [74.202.84.134]) by svr4.postgresql.org (Postfix) with ESMTP id 262DE5AF8AC for ; Fri, 13 Apr 2007 18:47:50 +0000 (GMT) Received: from allhats.xcski.com (localhost.localdomain [127.0.0.1]) by list.xcski.com (Postfix) with ESMTP id 8008D4F00A7 for ; Fri, 13 Apr 2007 14:47:48 -0400 (EDT) Received: by allhats.xcski.com (Golgafrincham B Ark, from userid 406) id 103D841E039; Fri, 13 Apr 2007 14:47:48 -0400 (EDT) Date: Fri, 13 Apr 2007 14:47:48 -0400 From: Paul Tomblin To: pgsql-jdbc@postgresql.org Subject: What changed? Message-ID: <20070413184748.GA6562@allhats.xcski.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.1i 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/35 X-Sequence-Number: 16884 This code worked in various versions of Postgres up to and including 7.4 (as bundled with CentOS 4.3), but fails on 8.1 (as bundled with CentOS 5.0) with an exception about being unable to determine the type of parameter $2: java.sql.Timestamp startDBDate = null; if (startDate != null) { startDBDate = new java.sql.Timestamp(startDate.getTime()); } try { PreparedStatement stmt = con.prepareStatement( "SELECT " + SHOWLIST_COLUMNS + "FROM showlists s, showlistsplaylists sc " + "WHERE s.id = sc.showlistid AND " + " sc.playlistid = ? AND " + " (? IS NULL OR s.showtime >= ?) " + "ORDER BY screen, showtime"); int p = 1; stmt.setLong(p, playlistID); p++; if (startDate == null) { stmt.setNull(p, java.sql.Types.TIMESTAMP); p++; stmt.setNull(p, java.sql.Types.TIMESTAMP); p++; } else { stmt.setTimestamp(p, startDBDate); p++; stmt.setTimestamp(p, startDBDate); p++; } ResultSet rs = stmt.executeQuery(); SortedSet retList = parseShowListResultSet(con, rs, venueInfoList); stmt.close(); Based on something I saw in the list archives, I got it to work by casting the timestamp parameters using "?::timestamptz". But I'm wondering why that changed, and are there any other gotchas lurking? Should I cast any timestamp parameter to either ::timestamp or ::timestamptz depending on what it is in the db? -- Paul Tomblin http://blog.xcski.com/ I think I'd like to see a Simpsons episode starting up with Bart Simpson writing 'I will not attempt to undermine the Usenet Cabal'. -- J. D. Falk