[postgis-users] postgis with jdbc
AGilbert at korem.com
Tue Jan 10 07:52:19 PST 2006
Yes, I finally made it working last week, but thank you for your input.
My main problem is that I charged a PostGIS line table with FME, and
somehow FME added the lines as MULTIPOINT instead of MULTILINESTRING,
then it was unparsable causing errors etc... I recharged the table with
some options changes causing the table be really MULTILINESTRING for all
objects and now all is working perfectly.
The problem was not the JDBC driver, it was because AsText provided me
something like MULTIPOINT((0 0,1 1,2 2),(5 5,6 6)) who is unparsable and
in fact should have been MULTILINESTRING((0 0,1 1,2 2),(5 5,6 6)). I
Finaly instead I use AsBinary for better performance and I use the
PostGid object BinaryParser.parse() to create my PGgeometry object.
I have a special question getting no answer. I would like to avoid
charging all geometry in memory, i.e. having something to browse point
with a special reader. With my understanding I can't achieve this with
the PostGIS java object provided with PostGIS.jar. I would have to use
myself the WKB (well-know binary) specification. Does I'm wrong? It's
because I want to avoid to load the 100 000 points of a polygon in
memory to draw them for example, could be nice to be able to read one,
draw it, read another, draw it, etc... Usually in such produc it's the
way to do.
From: Markus Schaber [mailto:schabi at logix-tt.com]
Sent: January 10, 2006 10:17 AM
To: PostGIS Users Discussion
Cc: Vachon, Patrick
Subject: Re: [postgis-users] postgis with jdbc
Sorry for the late answer, I'd been on holidays lately.
Gilbert, Antoine wrote:
> The jdbc example provided by the documentation dosen't work for me.
> Given these 2 statements :
It seems that this is the Code for the pgjdbc 7.2 driver, it should be
Did you have a look at the example code delivered with the postgis
Ouch, your second command should be changed to use the PGbox3d instead
Also, did you notice that there are two other ways to initialize the
PostGIS driver extension, via automatic configuration (simply drop the
postgis jar into the same classpath location as the pgjdbc jar if you
use 8.0 or newer pgjdbc drivers), and via the DriverWrapper classes?
> Statement stmt = connection.createStatement();
> ResultSet rs = stmt.executeQuery("select \"STREET\",
> AsText(\"geom\") as geom from rue_test");
You select asText(geom) converts the geometry to a varchar which is then
returned to the client. The pgjdbc driver maps varchar to a string.
Try the following:
| ResultSet rs = stmt.executeQuery("select \"STREET\",
| \"geom\" as geom from rue_test");
This way, the server should tag the result as type "geometry" and not
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in EU! www.ffii.org
postgis-users mailing list
postgis-users at postgis.refractions.net
More information about the postgis-users