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)