Skip site navigation (1) Skip section navigation (2)

What changed?

From: Paul Tomblin <ptomblin(at)xcski(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: What changed?
Date: 2007-04-13 18:47:48
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
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());

      PreparedStatement stmt = con.prepareStatement(
                "SELECT    " +  SHOWLIST_COLUMNS +
                "FROM           showlists s, showlistsplaylists sc " +
                "WHERE = sc.showlistid AND " +
                "               sc.playlistid = ? AND " + 
                "               (? IS NULL OR >= ?) " +
                "ORDER BY       screen, showtime");
      int               p = 1;
      stmt.setLong(p, playlistID);
      if (startDate == null)
        stmt.setNull(p, java.sql.Types.TIMESTAMP);
        stmt.setNull(p, java.sql.Types.TIMESTAMP);
        stmt.setTimestamp(p, startDBDate);
        stmt.setTimestamp(p, startDBDate);

      ResultSet rs      = stmt.executeQuery();
      SortedSet retList = parseShowListResultSet(con, rs, venueInfoList);


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 <ptomblin(at)xcski(dot)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


pgsql-jdbc by date

Next:From: Mark LewisDate: 2007-04-13 19:16:14
Subject: Re: What changed?
Previous:From: Kris JurkaDate: 2007-04-12 23:17:56
Subject: Re: Small addition to PGInterval

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group