((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'
((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);
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);