| From: | javadesigner <javadesigner(at)yahoo(dot)com> |
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org |
| Subject: | PreparedStatement error upon trying to set a '?' after interval keyword |
| Date: | 2014-08-11 19:06:51 |
| Message-ID: | 53E9144B.4010404@yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-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
`
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Sehrope Sarkuni | 2014-08-11 20:34:29 | Re: PreparedStatement error upon trying to set a '?' after interval keyword |
| Previous Message | Leonard Meyer | 2014-08-08 07:51:21 | waitOnLOck on several threads when db connection lost |