From: ste.buffaishere@tin.it <ste.buffaishere@tin.it>
To: pgsql-jdbc@postgresql.org
Subject: Prepared statement parameter and timestamp
Date: Tue, 3 Apr 2007 10:28:29 +0100 (GMT+01:00)
Message-ID: <111b6c6205e.ste.buffaishere@tin.it> (raw)
Why this code:
PreparedStatement ps = conn.prepareStatement(
"SELECT date_trunc('week', {ts ?})");
ps.setTimestamp(1, new java.sql.
Timestamp(
new java.util.Date().getTime()));
ResultSet rs = ps.
executeQuery();
while(rs.next()) {
debug(rs.getString(1));
}
fails miserably with
org.postgresql.util.PSQLException: ERROR: syntax
error at or near "$1"
at org.postgresql.core.v3.
QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
at org.postgresql.core.v3.QueryExecutorImpl.processResults
(QueryExecutorImpl.java:1313)
at org.postgresql.core.v3.
QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
at org.
postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.
java:452)
at org.postgresql.jdbc2.AbstractJdbc2Statement.
executeWithFlags(AbstractJdbc2Statement.java:354)
at org.
postgresql.jdbc2.AbstractJdbc2Statement.executeQuery
(AbstractJdbc2Statement.java:258)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: ste.buffaishere@tin.it
Subject: Re: Prepared statement parameter and timestamp
In-Reply-To: <111b6c6205e.ste.buffaishere@tin.it>
References: <111b6c6205e.ste.buffaishere@tin.it>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox