[postgis-users] JDBC and PostGIS
schabi at logix-tt.com
Wed Jun 29 09:57:05 PDT 2005
Gustavo Henrique Sberze Ribas wrote:
> And tried this simple insert query:
> Point p = new Point(-47.12, -22.374);
> PreparedStatement ps = conn.prepareStatement("INSERT INTO jdbc_test(geom,id) VALUES(?,?)");
> --> ps.setObject(1, p); // replaces first "?" so geom = Point(-47.12, -22.374)
Try ps.setObject(1, new org.postgis.PGgeometry(geom));
Currently, the pgjdbc driver does only recognize a single PGObject
subclass for any PostgreSQL type, and this model is not flexible enough
for a real geometry model where several different subclasses match the
different OpenGIS geometry types which are all modeled as "geometry"
type in PostgreSQL.
Because of this, the PGgeometry wrapper is needed, maybe the docs and
comments in the example files of the PostGIS jdbc2 code will enlighten you.
This problem was invisible when using pgjdbc 7.X or when running against
an old server that uses the V2 protocol, because everything was
converted to Strings. With the 8.X drivers against a V3 server (7.4 or
newer, I think), this behaviour changed.
There are some ideas on how to change the infrastructure on the pgjdbc
side, but none of them was implemented yet. I began to work on it
myself, but currently, some time constraints prevented me to continue it.
More information about the postgis-users