[postgis] PostGIS JDBC

Henry Holland hjholland at gmx.net
Mon Mar 4 23:13:40 PST 2002


Admittedly I haven't checked the documentation, but I'd think that
AsText() returns a String and you are trying to cast it to a PGgeometry
class. Should you perhaps try something like:

String polyStr = (String)resultSet.getObject(2);
PGgeometry polygon = new PGgeometry( polyStr );

Assuming there's a constructor for PGgeometry that takes an appropriate
String.

Appologies if I'm leading you completely the wrong way:)

Henry
ps. just checked the TestServer.java in the postgis examples folder and
the query is 'Select * from jdbc_test;', which means they don't use
AsText() in the query if the postgis datatypes have been established for
the connection. Also, there seems to be a constructor for PGgeometry, so
the above code may work.

On Sun, 3 Mar 2002, bouabdaddy wrote:

> Hi everyone,
>
> can anybody help me out with the following runtime error:
>
> Exception occurred during event dispatching:
> java.lang.ClassCastException: java.lang.String
>         at canned_classes.JDBCAdapter.executeGISQuery
> (JDBCAdapter.java:89)
>         at canned_classes.QueryToolInterface.fetchSiteBoundaries
> (QueryToolInterface.java:200)
>         at canned_classes.QueryToolInterface$3.actionPerformed
> (QueryToolInterface.java:130)
>
>
>
> This is the code at line 89 JDBCAdapter.java
>
> PGgeometry polygon = (PGgeometry)resultSet.getObject(2);
> System.out.println("Got site_boundary:");
> System.out.println(polygon.toString());
>
> This is the code at line 200 QueryToolInterface.java:
>
> //this line calles the method executeGISQuery in JDBCAdapter.java
> which trips up at the codes above
>
> dataBase.executeGISQuery("select boundary_id, AsText
> (external_boundary) as external_boundary, Astext(site_centroid) as
> site_centroid from geom_site_boundary;");
>
>
>
>
> I have included the following additions to the data types of the
> Postgresql connection:
>
> 	    ((org.postgresql.Connection)connection).addDataType
> ("geometry","org.postgis.PGgeometry");
> 	    ((org.postgresql.Connection)connection).addDataType
> ("multipolygon","org.postgis.MultiPolygon");
>     	((org.postgresql.Connection)connection).addDataType
> ("box3d","org.postgis.PGbox3d");
> 	    ((org.postgresql.Connection)connection).addDataType
> ("polygon","org.postgis.Polygon");
>        	((org.postgresql.Connection)connection).addDataType
> ("point","org.postgis.Point");
>
> and of course: import org.postgis.*;
>
> Best regards
>
> Ismail
>
>
>
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe at yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Tiny Wireless Camera under $80!
Order Now! FREE VCR Commander!
Click Here - Only 1 Day Left!
http://us.click.yahoo.com/nuyOHD/7.PDAA/yigFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
postgis-unsubscribe at yahoogroups.com

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 





More information about the postgis-users mailing list