From: | "ste(dot)buffaishere(at)tin(dot)it" <ste(dot)buffaishere(at)tin(dot)it> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Prepared statement parameter and timestamp |
Date: | 2007-04-03 09:28:29 |
Message-ID: | 111b6c6205e.ste.buffaishere@tin.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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)
From | Date | Subject | |
---|---|---|---|
Next Message | Marc Mamin | 2007-04-05 14:48:41 | Encoding issue (utf8): different strings received from java than from PGAdmin |
Previous Message | Oliver Jowett | 2007-04-03 02:23:19 | Re: psql COPY with JDBC |