[postgis-users] postgis with jdbc
Gilbert, Antoine
AGilbert at korem.com
Fri Jan 6 05:58:37 PST 2006
Hi
I just installed PostgreSQL 8.1, supposed to be packaged with postgis
1.0.4
So far I have 2 questions
The jdbc example provided by the documentation dosen't work for me.
Given these 2 statements :
((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PG
geometry");
((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox
3d");
This object doesn't exists : org.postgresql.Connection, I tried with
org.postgresql.PGConnection, but I keep getting class cast exceptions
when doing rs.getObject().. (if I do getString(2) all ok)
Here is my complete test code :
((PGConnection)connection).addDataType("geometry","org.postgis.PGgeometr
y");
((PGConnection)connection).addDataType("box3d","
org.postgis.PGgeometry");
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select \"STREET\",
AsText(\"geom\") as geom from rue_test");
ResultSetMetaData rsmd = rs.getMetaData();
for(int i=0;i<rsmd.getColumnCount();i++)
System.out.println("column"+(i+1)+":"+rsmd.getColumnName(i+1));
while(rs.next()){
String street = rs.getString(1);
//System.out.println(rs.getObject(2).getClass().getName()+":"+rs.getStri
ng(2));
PGgeometry geometry = (PGgeometry)rs.getObject(2);
}
Second question. I loaded some line objects on my postgressql database
with FME, and the objects are flagged as MULTIPOINT, I would have
expected these objects to be of type LINE or MULTILINE instead.
Neverlesss, when I use some viewers to see these objects they show as
lines (FME viewer). Where I can find real explanations about all
geometry types used by postgis. (sorry but the postgis doc doesn't help)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060106/a0b8edf4/attachment.html>
More information about the postgis-users
mailing list