<DIV id=RTEContent>Thanks a loooooooot.This helped.How can I retreive the data inside my database though( the coordinates of my point). With getObject (besides getClass) there aren't a lot of methods? Are we able to cast the object we retreive fron postgis to say " Point" so we can use the getX () and getY() methods?<BR><BR><B><I>Emily Gouge <egouge@refractions.net></I></B> wrote:  <BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Fatemeh,<BR><BR>If you are using an attribute type of Circle you are not using the PostgreSQL data types and not the <BR>PostGIS geometry objects. So if you want to use the PostGIS geometry functions you need to create <BR>PostGIS Geometry objects using the AddGeometryColumns() function.<BR><BR>For further information see: http://postgis.refractions.net/docs/ch04.html#id2787299<BR><BR><BR>The following code will return PGGeometries; however you must have the postgis.jar,
 <BR>postgresql-7.4.1-jdbc3.jar on your class path. If you are using postgres 8.1 then you can have the <BR>postgres81 jar in replace of the 7.4.1 jar, however you will note that the addDataType function will <BR>be depreciated (the newer version takes a class instead of a String).<BR><BR>Class.forName("org.postgresql.Driver");<BR>Connection c= DriverManager.getConnection("jdbc:postgresql://turtle:5432/cwb_devel","egouge", "" );<BR>((PGConnection) c).addDataType("geometry", "org.postgis.PGgeometry" ); //for 8.1 change to <BR>addDataType("geometry", org.postgis.PGgeometry.class );<BR><BR>ResultSet rs = c.createStatement().executeQuery("SELECT the_geom from table_name");<BR>while(rs.next()){<BR>System.out.println(rs.getObject(1).getClass());<BR>}<BR><BR><BR>-Emily<BR><BR>Fatemeh Abbasinejad wrote:<BR>> Hi.<BR>> I sae the code and tried to execute it on my own tables.Ther were some problems:<BR>> First when trying to add data types it would give me a warning that the method
 addDataType has been deprecated.<BR>> Also when I tried to cast to PGeometry it would throw "ClassCastException".Here is my code:<BR>> <BR>> ((PGConnection)conn).addDataType("geometry","org.postgis.PGgeometry");<BR>> <BR>> Statement s = conn.createStatement(); <BR>> ResultSet r = s.executeQuery("select center(geometry)as mycenter from land"); <BR>> <BR>> while( r.next() ) <BR>> { <BR>> PGgeometry mycenter = (PGgeometry)r.getObject(1); <BR>> System.out.println(mycenter.toString()); <BR>> }<BR>> <BR>> I have a table called "land" which has an attribute "geometry" of type Circle.I want to retreive the center of the circle which is of type "Point".<BR>> Have I casted wrong? I also tried casting to "Point" but it would give the same exception. What should I do?<BR>> <BR>> <BR>> <BR>> Emily Gouge <EGOUGE@REFRACTIONS.NET>wrote:<BR>> Hi,<BR>> <BR>> There is some documentation and an example on connecting to PostGIS using
 Java. See:<BR>> http://postgis.refractions.net/docs/ch04.html#id2789526<BR>> <BR>> You can add a datatype to the postgres connection and then the getObject() call will return a <BR>> PGGeometry object:<BR>> ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");<BR>> <BR>> Additionally you can also check out the postgis_jts jar, which provides the ability to return a <BR>> JtsGeometry object (and subsequently to convert this object to a JTS Geometry object).<BR>> <BR>> Emily<BR>> <BR>> <BR>> <BR>> Fatemeh Abbasinejad wrote:<BR>>> I am new to PostGIS. Does anyone know how we can retrieve our defined data types <BR>>> (like point,circle,...) from a ResultSet in java. I used getObject but it didn't work. <BR>>> -fatemeh<BR>>><BR>>><BR>>> ---------------------------------<BR>>> Bring words and photos together (easily) with<BR>>> PhotoMail - it's free and works with
 Yahoo! Mail.<BR>>><BR>>><BR>>> ------------------------------------------------------------------------<BR>>><BR>>> _______________________________________________<BR>>> postgis-users mailing list<BR>>> postgis-users@postgis.refractions.net<BR>>> http://postgis.refractions.net/mailman/listinfo/postgis-users<BR>> <BR>> _______________________________________________<BR>> postgis-users mailing list<BR>> postgis-users@postgis.refractions.net<BR>> http://postgis.refractions.net/mailman/listinfo/postgis-users<BR>> <BR>> <BR>> <BR>> <BR>> ---------------------------------<BR>> <BR>> What are the most popular cars? Find out at Yahoo! Autos <BR>> <BR>> <BR>> ------------------------------------------------------------------------<BR>> <BR>> _______________________________________________<BR>> postgis-users mailing list<BR>> postgis-users@postgis.refractions.net<BR>>
 http://postgis.refractions.net/mailman/listinfo/postgis-users<BR><BR>_______________________________________________<BR>postgis-users mailing list<BR>postgis-users@postgis.refractions.net<BR>http://postgis.refractions.net/mailman/listinfo/postgis-users<BR></BLOCKQUOTE><BR></DIV><p>
                <hr size=1> <BR> 
What are the most popular cars? Find out at <a href="http://us.rd.yahoo.com/evt=38382/_ylc=X3oDMTEzNWFva2Y2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDMmF1dG9z/*http://autos.yahoo.com/newcars/popular/thisweek.html 
">Yahoo! Autos</a>