Thank you mailto me. Re: [postgis-users] Postgis problem : Can not compile the code successful
John
john123apple at 163.com
Tue Oct 21 23:47:56 PDT 2008
Hello Kevin:
Thanks you send message to me, these days I solve one problem;
In Postgis DOCUMENTATION,the source code is:
((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
the right code is:
((org.psotgresql.jdbc3.Jdbc3Connection)conn).addDataType ("geometry","org.postgis.PGgeometry");
I seek the postgresql.jar and postgis-1.3.3.jar.
But another problem is appeared.
The code is:
PGgeometry geom = (PGgeometry)r.getObject(1);
System.out.println(geom.toString());
But I do not know how to solve the problem.
I use the computer language is jsp+Tomcat6.0 +JDK1.5.
Cheers,
john
在2008-10-21,"Kevin Neufeld" <kneufeld at refractions.net> 写道:
>Yeah, I was never fond of the postgis driver myself. Someday we'll have
>to revisit that.
>
>I use JTS rather than PGgeometry to read and write JTS Geometry objects
>... works very well.
>http://postgis.refractions.net/pipermail/postgis-users/2007-March/014911.html
>
>Cheers,
>Kevin
>
>John wrote:
>>
>>
>> My name is john, this day i have some problem about Postgis,
>>
>> I have readed Postgis Documentation, and try to compile source code.
>>
>> I am using Postgresql 8.2.10 version,and using the computer
>> language's java.
>>
>> I use the JDK 1.5 and Tomcat 6.0.
>>
>> In postgis-1.3.3.pdf source code is:
>>
>> 4.8 Java Clients (JDBC)
>>
>> import java.sql.*;
>> import java.util.*;
>> import java.lang.*;
>> import org.postgis.*;
>> public class JavaGIS {
>> public static void main(String[] args) {
>> java.sql.Connection conn;
>> try {
>> /*
>> * Load the JDBC driver and establish a connection.
>> */
>> ClassforName("org.postgresql.Driver");
>> String url = "jdbc:postgresql://localhost:5432/database";
>> conn = DriverManager.getConnection(url, "postgres", "");
>> /*
>> * Add the geometry types to the connection. Note that you
>> * must cast the connection to the pgsql-specific connection
>> * implementation before calling the addDataType() method.
>> */
>> ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
>>
>> ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
>> /*
>> * Create a statement and execute a select query.
>> */
>> Statement s = conn.createStatement();
>> ResultSet r = s.executeQuery("select AsText(geom) as geom,id from
>> geomtable");
>> while( r.next() ) {
>> /*
>> * Retrieve the geometry as an object then cast it to the geometry type.
>> * Print things out.
>> */
>> PGgeometry geom = (PGgeometry)r.getObject(1);
>> int id = r.getInt(2);
>> System.out.println("Row " + id + ":");
>> System.out.println(geom.toString());
>> }
>> s.close();
>> conn.close();
>> }
>> catch( Exception e ) {
>> e.printStackTrace();
>> }
>> }
>> }
>>
>> I can not compile this code successful, always report wrong .
>>
>> can you help me, send the right code to my email.
>>
>> Thanks
>>
>> john
>>
>>
>>
>>
>> ------------------------------------------------------------------------
>> [广告] 金秋最关注楼盘-房不胜房
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20081022/35917766/attachment.html>
More information about the postgis-users
mailing list