Re: Prepared statement with function as argument: how to bind values?

From: Maciek Sakrejda <msakrejda(at)truviso(dot)com>
To: alexbruy <alexander(dot)bruy(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepared statement with function as argument: how to bind values?
Date: 2011-09-26 16:38:42
Message-ID: CAH_hXRYymS=GUqv+3duQzuMavbpHyJqoP5Afv1EKvV2M2htMOw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> String sql = "INSERT INTO
> poi(geom,latitude,longitude,description,comment) VALUES
> (ST_GeomFromText('POINT(? ?)', 4326), ?, ?, ?, ?)";
> stmt = conn.prepareStatement(sql);
>
> stmt.setFloat(1, lon);
> stmt.setFloat(2, lat);
> stmt.setFloat(3, lon);
> ...

Well, I'm still not sure what's going on. That doesn't seem like it
would correspond to the error message. For what it's worth, what I was
suggesting is

String sql = "INSERT INTO
poi(geom,latitude,longitude,description,comment) VALUES
(ST_GeomFromText('POINT(? ?)', 4326), ?, ?, ?, ?)";
stmt = conn.prepareStatement(sql);

stmt.setString(1, "POINT(" + lon + "," + lat + ")");
stmt.setFloat(2, lon);
stmt.setFloat(3, lat);
...

---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message David Rees 2011-09-26 19:43:55 Re: 9.1 driver status
Previous Message Mike Fowler 2011-09-26 14:17:02 Re: Buildfarm error: Broken compatability with JDK 1.4