From: javadesigner <javadesigner@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: PreparedStatement error upon trying to set a '?' after interval keyword
Date: Mon, 11 Aug 2014 15:06:51 -0400
Message-ID: <53E9144B.4010404@yahoo.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Hi:
postgres: 9.3.4
driver: postgresql-9.3-1102.jdbc4.jar
I have the following query:
select
count(*) from checkin
where
pid = ? and checkin_time > current_date - interval '? days'
When I try to set the interval (parameter 2, second question mark):
ps.setLong("pid", 123);
ps.setInt("interval_days", 7);
I get the following error:
ERROR org.postgresql.util.PSQLException: The column index is out of
range: 2, number of columns: 1
at
org.postgresql.core.v3.SimpleParameterList.bind(SimpleParameterList.java:56)
=====
I looked at the mailing list archives and whereas others have seen the
same issue, I am trying to understand the root cause of why the JDBC
driver throws an error here ? Should it just set the location of the
second question mark, with the specified data type (in this case in
integer) ? What's the point of throwing an error, why does the
preparedstatement care ? Its job is to simply replace question marks
with the specified data type, right ?
Best
--j
`
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: javadesigner@yahoo.com
Subject: Re: PreparedStatement error upon trying to set a '?' after interval keyword
In-Reply-To: <53E9144B.4010404@yahoo.com>
References: <53E9144B.4010404@yahoo.com>
* 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