From: Dave Cramer <pg@fastcrypt.com>
To: Simon Mitchell <simon@jseb.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement error for date parameter with overlaps
Date: Mon, 30 May 2011 21:47:58 -0400
Message-ID: <BANLkTin_rdrH=_MyQFddkNoCW1wC0bXmoQ@mail.gmail.com> (raw)
In-Reply-To: <BANLkTikCY4ax50aOqNy2BdoYEoLSdc1Sew@mail.gmail.com>
References: <BANLkTikCY4ax50aOqNy2BdoYEoLSdc1Sew@mail.gmail.com>
On Mon, May 30, 2011 at 8:39 AM, Simon Mitchell <simon@jseb.com> wrote:
> jdbc driver issue for PreparedStatement error for date parameter with
> overlaps
> // some bad code
> sqlText = "SELECT (date ?, date ?) OVERLAPS (date ?, date ?);";
> System.out.println("Executing this command: "+sqlText+"\n");
> PreparedStatement prs = db.prepareStatement(sqlText);
> prs.setString(1,"2001-02-16");
> prs.setString(2,"2001-12-21");
> prs.setString(3,"2001-10-30");
> prs.setString(4,"2002-10-30");
> System.out.println("Executing this command: "+ prs.toString() +"\n");
> ResultSet results = prs.executeQuery();
> // error
> ***Exception:
> org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1"
> Position: 14
> Found a work around, changing the query to include brackets around the
> question marks works.
> sqlText = "SELECT (date (?), date (?)) OVERLAPS (date (?), date (?))";
> Is this a bug?
> --
> simon
>
Doesn't look like a bug. I don't think you can write that SQL in psql.
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
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: pg@fastcrypt.com, simon@jseb.com
Subject: Re: PreparedStatement error for date parameter with overlaps
In-Reply-To: <BANLkTin_rdrH=_MyQFddkNoCW1wC0bXmoQ@mail.gmail.com>
References: <BANLkTikCY4ax50aOqNy2BdoYEoLSdc1Sew@mail.gmail.com> <BANLkTin_rdrH=_MyQFddkNoCW1wC0bXmoQ@mail.gmail.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