[postgis-users] ClassCastException

Tore Halset halset at pvv.ntnu.no
Wed Jun 2 04:43:30 PDT 2004


Hello.

I am new to postgis and have just installed postgresql-7.4.2 with 
postgis-0.8.1. I installed postgis with proj and geos. I have created a 
postgis database and loaded in some data using ogr2ogr. Then over to 
the java world..

I have followed the example at http://www.postgis.org/docs/x655.html 
but it does not work... I had to switch from org.postgresql.Connection 
to PGConnection.

I add inn the additional types:
             ((PGConnection) conn).addDataType("geometry", 
"org.postgis.PGgeometry");
             ((PGConnection) conn).addDataType("box3d", 
"org.postgis.PGbox3d");

r.getObject(1) does return a String instead of a PGgeometry so I get a 
ClassCastException. Switching from
                 PGgeometry geom = (PGgeometry) r.getObject(1);
to
                 PGgeometry geom = new PGgeometry(r.getString(1));
fixes the problem.

Is this a faq? What am I doing wrong?

Regards,
  - Tore.




More information about the postgis-users mailing list