[postgis-users] Re: JDBC PreparedStatements and inserting geometries...

Markus Schaber schabios at logi-track.com
Sat Feb 26 00:35:49 PST 2005


Hi, Corey,

Corey Puffalt schrieb:
> I discovered a solution (not sure if this is the best solution or not
> -- maybe an expert could comment?) to my problem.  That was to
> parameterize everything inside the single quotes (as I had already
> tried) and to wrap that inside a call to text().  I stumbled across
> the text() method mentioned in another email in the archive... though
> I haven't yet found documentation on what it does...

It casts it input value to text, for some input types.

> insertStmt.setObject(3, "'MULTILINESTRING ((" + geometry + "))'");

You should really use setString() here, so the PGJDBC driver knows that
you insert text. This also avoids using text(). Current jdbc drivers
have deprecated the untyped setObject(id, obj) calls.

Markus

-- 
markus schaber | dipl. informatiker
logi-track ag | rennweg 14-16 | ch 8001 zürich
phone +41-43-888 62 52 | fax +41-43-888 62 53
mailto:schabios at logi-track.com | www.logi-track.com



More information about the postgis-users mailing list