2 messages in org.postgresql.pgsql-jdbcRe: JDBC 7.4 to 8.1 regression problem
FromSent OnAttachments
Carsten FriedrichJul 13, 2006 7:01 pm 
Tom LaneJul 14, 2006 9:14 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: JDBC 7.4 to 8.1 regression problem Actions...
From:Tom Lane (tg@sss.pgh.pa.us)
Date:Jul 14, 2006 9:14:38 am
List:org.postgresql.pgsql-jdbc

"Carsten Friedrich" <cars@dtecht.com.au> writes:

I use the following prepared statement:

final static String SQL= "SELECT " + [...] " WHERE " + [...] + " AND service_date <= ?" + " and service_date > date ? - interval '365 days'; "

The above is broken code, and always has been: the fact that it failed to malfunction back in 7.4 was purely accidental. You can only use the syntax "typename literal" with a literal constant. Instead of "date ?" use "?::date", or if you want to be fully SQL-spec-compliant write it out as "CAST(? AS date)".

Actually, it'd probably be better to use "date_trunc('day', ?)" anyway, since that's what you're trying to achieve with the cast.