[postgis-users] Postgis problem : Can not compile the code successful

Kevin Neufeld kneufeld at refractions.net
Tue Oct 21 08:35:14 PDT 2008


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
> 
>     
> 
> 
> ------------------------------------------------------------------------
> [¹ã¸æ] ½ðÇï×î¹Øע¥ÅÌ-·¿²»Ê¤·¿ 
> <http://popme.163.com/link/003985_1010_7027.html>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list