]> granicus.if.org Git - postgis/commitdiff
Patches to bring example up to current version in terms of SQL access
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 19 Apr 2002 15:14:17 +0000 (15:14 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 19 Apr 2002 15:14:17 +0000 (15:14 +0000)
and to stop silly bug in missing table case. Submitted by
Steffen Macke <sdteffen@web.de>

git-svn-id: http://svn.osgeo.org/postgis/trunk@135 b70326c6-7e19-0410-871a-916f4a2858ee

jdbc/README
jdbc/examples/TestServer.java

index 6a1abb2bbb0e72e20569790589aa5a77f85433bd..f4551df9951e64d42dabcc0a0ee3ece2d29741ee 100644 (file)
@@ -6,4 +6,10 @@ To use the PostGIS types, you must:
   ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
   ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
 
-- 
+To build the examples:
+- put the jar file containing the PostgreSQL JDBC under 
+  postgis/original/jars/postgresql.jar
+  The file might be named jdbc7.1-1.2.jar originally
+
+- edit the file TestServer.java to adjust the connection information, run
+  the test with 'make jtest'
index c94133fab7b5d7aadf491bf232f65862305b6d72..0c5ca58d13dc7d51ade3df40f3208d93ff8a6711 100644 (file)
@@ -36,7 +36,12 @@ public class TestServer
                        ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
                        Statement s = conn.createStatement();
                        System.out.println("Creating table with geometric types...");
-                       s.execute(dropSQL);
+                       //table might not yet exist
+                       try {
+                           s.execute(dropSQL);
+                       } catch(Exception e) {
+                           e.printStackTrace();
+                       }
                        s.execute(createSQL);
                        System.out.println("Inserting point...");
                        s.execute(insertPointSQL);
@@ -45,7 +50,7 @@ public class TestServer
                        System.out.println("Done.");
                        s = conn.createStatement();
                        System.out.println("Querying table...");
-                       ResultSet r = s.executeQuery("select * from " + dbtable);
+                       ResultSet r = s.executeQuery("select asText(geom),id from " + dbtable);
                        while( r.next() ) 
                        {
                                Object obj =  r.getObject(1);