Something wrong with binding timestamp values

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Something wrong with binding timestamp values
Date: 2006-12-06 13:58:31
Message-ID: 200612061458.32156.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

This code

PreparedStatement st = conn.prepareStatement("SELECT date_trunc('day', ?)");
st.setString(1, "2006-12-17");
ResultSet rs = st.executeQuery();

fails, as might be expected, because date_trunc(unknown, varchar)
doesn't exist.

But this code:

PreparedStatement st = conn.prepareStatement("SELECT date_trunc('day', ?)");
st.setTimestamp(1, new Timestamp(222222222));
ResultSet rs = st.executeQuery();

fails with postgresql-8.1-408.jdbc3.jar with

ERROR: function date_trunc("unknown", "unknown") is not unique

It works correctly with postgresql-8.0-318.jdbc3.jar.

What is wrong here? Why does a timestamp value end up being bound as
"unknown"?

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Mark Lewis 2006-12-06 14:38:15 Re: Something wrong with binding timestamp values
Previous Message Brendon Bentley 2006-12-05 12:27:32 Re: Use Driver to Create database?