#609 closed defect (fixed)
Bad source code in manual section 5.2 Java Clients
Reported by: | simoc | Owned by: | pramsey |
---|---|---|---|
Priority: | low | Milestone: | PostGIS 1.5.3 |
Component: | postgis | Version: | 1.5.X |
Keywords: | history JDBC client documentation | Cc: |
Description
I found some errors in the example Java source code in section 5.2 'Java Clients (JDBC)' of postgis-1.5.1.pdf:
Replace:
((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry"); ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
with:
((org.postgresql.jdbc3.Jdbc3Connection)conn).addDataType("geometry","org.postgis.PGgeometry"); ((org.postgresql.jdbc3.Jdbc3Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
Replace:
ResultSet r = s.executeQuery("select ST_AsText(geom) as geom,id from geomtable");
with:
ResultSet r = s.executeQuery("select geom,id from geomtable");
Replace:
if( geom.getType() = Geometry.POLYGON ) {
with:
if( geom.getGeoType() == Geometry.POLYGON ) {
Change History (4)
comment:1 by , 14 years ago
comment:2 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Okay I feel the recommendation for first part is wrong. Last bit of java programming I tortured myself with — I think I used this syntax — http://jdbc.postgresql.org/documentation/publicapi/org/postgresql/PGConnection.html and a JDBC4 driver.
So I have instead opted to replace the first part with
((org.postgresql.PGConnection)conn).addDataType("geometry","org.postgis.PGgeometry"); ((org.postgresql.PGConnection)conn).addDataType("box3d","org.postgis.PGbox3d");
the rest of the suggestions look fine, but I haven't tested the code and am not really setup to at the moment.
comment:3 by , 13 years ago
Yes, using PGConnection.addDataType(String, String) also works for me, although that method is deprecated. The recommended replacement method in the PGConnection Javadoc is:
((org.postgresql.PGConnection)conn).addDataType("geometry",Class.forName("org.postgis.PGgeometry")); ((org.postgresql.PGConnection)conn).addDataType("box3d",Class.forName("org.postgis.PGbox3d"));
That method also works correctly for me.
comment:4 by , 13 years ago
Keywords: | history added |
---|
Documentation source file to be updated is doc/using_postgis_app.xml