[postgis-users] RE: JDBC - Error in the user document

Markus Schaber schabi at logix-tt.com
Mon Nov 21 14:47:30 PST 2005


Hi, Willa,

Willa WEI schrieb:

> Just thought I should let you know that there is an error in the postGIS
> manual. 
> 
> When I tried the JDBC sample code in the manual, I got a runtime error
> message. It complained the line:
> 
> Pggeometry geom = (Pggeometry).r.getObject(1);

Hmm, I searched the manual that is online at postgis.refractions.net and
did not find the example line you quoted above. Could you give us the
exact source where you did get the example?

The following should work (I marked the differences with ^):

  PGgeometry geom = (PGgeometry) r.getObject(1);
   ^                  ^         ^

Did you execute the addDataTypes() commands given in the example in the
manual? Btw, the jdbc code is outdated, use the jdbc2 code instead.

You also should have a look at the README and the examples in the jdbc2
subdirectory, they are more sophisticated as the postgis manual (which
should be updated wr/t jdbc2, I'm afraid...) and are guaranteed to have
worked at least enough to pass the included regression tests.

> PGgeometry geom = new PGgeometry(r.getObject(1).toString());

This works, but it is high overhead, as r.getObject() already is a
PGgeometry instance. You convert it into the string representation, just
to have it parsed into a new PGgeometry instance again.

> Then it worked. So, I guess you did fix the problem, but in a different
> way. It will be nice if you could update the document as well.

Yes, it seems that we have to do that, thanks for the hints.

HTH,
Markus



More information about the postgis-users mailing list