[postgis-users] How to instanziate the Geometry class from the geometry string?

Markus Schaber schabi at logix-tt.com
Thu Oct 5 13:45:47 PDT 2006


Hi, Francesco,

martinelli at pi.ingv.it wrote:

> during my last email I thought I got the solution, as method
> org.postgis.binary.binaryWriter.writeHexed()
> 
> returned the same string as I received from the database, and indeed the
> same string as showed querying pgadmin3.
> 
> Nevertheless, when I moved my sptes forward and tried to really connect to
> the databse for updating the geometry data, the following error came up:
> org.postgresql.util.PSQLException: ERROR: column "the_geom" is of type
> geometry but expression is of type character

Did you wrap the String into an appropriate PGobject, and use
setObject() to set it in the prepared statement?

If you use setString(), the JDBC driver tells the server that the type
is Text.

Another possibility to cope with this is using an explicit cast in the
statement, like:

INSERT INTO mytable (the_geom) VALUES (?::geometry);

HTH,
Markus


-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org



More information about the postgis-users mailing list