Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 3F104B5F6C5 for ; Mon, 30 May 2011 22:48:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 89302-01 for ; Tue, 31 May 2011 01:48:19 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f46.google.com (mail-fx0-f46.google.com [209.85.161.46]) by mail.postgresql.org (Postfix) with ESMTP id BE4C9B5F4BB for ; Mon, 30 May 2011 22:48:18 -0300 (ADT) Received: by fxm17 with SMTP id 17so2734450fxm.19 for ; Mon, 30 May 2011 18:48:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:from :date:x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=2hJjo0AKo1Rl5T1LPyZwDWgs6cm7kkURuizNkKYbMDI=; b=AbY1ZnevBJJQdNLnE1Po0KesarqD/F72q0sVi3rrqu7mZ4CBpisZ2vr3m8zSO9F9C/ rZ9OjpYShXKIcGWIrB+hWzeQWk9LeLXSZGHRalMY/DjyIycO5v4jbJcNqCPsRn0G1OzQ TI1+JHPQdwLGV4ZYBIgKkS67F1e7LTkVjtw/I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; b=w3Yb5B688/5L93tevtXmhkeMM3fvR1bYEYmeNmtKfLhb1onySiItHxkdQCXRhud/w9 P2bfFWdrKVD46+QW/8BUmhCgNn5AYlPnZpY1dTgv6GFfQM53vN89GxAw55lajCLYENt4 Q8vt/a2JbuyjImG6ao9TvGlPwTUajB95/TMVM= Received: by 10.223.57.86 with SMTP id b22mr6459828fah.95.1306806498206; Mon, 30 May 2011 18:48:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.101.81 with HTTP; Mon, 30 May 2011 18:47:58 -0700 (PDT) In-Reply-To: References: From: Dave Cramer Date: Mon, 30 May 2011 21:47:58 -0400 X-Google-Sender-Auth: F169OB4KuFNcofCdxmoMaOsMxP0 Message-ID: Subject: Re: PreparedStatement error for date parameter with overlaps To: Simon Mitchell Cc: pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/81 X-Sequence-Number: 21911 On Mon, May 30, 2011 at 8:39 AM, Simon Mitchell wrote: > =A0 =A0 jdbc driver issue for=A0PreparedStatement error for date paramete= r with > overlaps > // some bad code > =A0 =A0 sqlText =3D "SELECT (date ?, date ?) OVERLAPS (date ?, date ?);"; > =A0 =A0 System.out.println("Executing this command: "+sqlText+"\n"); > =A0 =A0 PreparedStatement prs =3D db.prepareStatement(sqlText); > =A0 =A0 prs.setString(1,"2001-02-16"); > =A0 =A0 prs.setString(2,"2001-12-21"); > =A0 =A0 prs.setString(3,"2001-10-30"); > =A0 =A0 prs.setString(4,"2002-10-30"); > =A0 =A0 System.out.println("Executing this command: "+ prs.toString() +"\= n"); > =A0 =A0 ResultSet results =3D prs.executeQuery(); > // error > ***Exception: > org.postgresql.util.PSQLException: ERROR: syntax error at or near "$1" > =A0 Position: 14 > Found a work around, changing the query to include=A0brackets=A0around th= e > question marks works. > =A0 =A0 sqlText =3D "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