Re: Prepared statement with function as argument: how to bind values? - Mailing list pgsql-jdbc

From Maciek Sakrejda
Subject Re: Prepared statement with function as argument: how to bind values?
Date
Msg-id CAH_hXRYymS=GUqv+3duQzuMavbpHyJqoP5Afv1EKvV2M2htMOw@mail.gmail.com
Whole thread Raw
In response to Re: Prepared statement with function as argument: how to bind values?  (alexbruy <alexander.bruy@gmail.com>)
List 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

pgsql-jdbc by date:

Previous
From: Mikko Tiihonen
Date:
Subject: Re: Buildfarm error: Broken compatability with JDK 1.4
Next
From: David Rees
Date:
Subject: Re: 9.1 driver status