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

Willa WEI wwei at mdacorporation.com
Mon Nov 21 17:26:29 PST 2005


Hi Markus

Sorry, it was a typo when I posted the message. I used

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

in my code before and it gave me runtime "java.lang.ClassCastException:
java.lang.String." error. Now when I tried it again, it works. Maybe I
used a wrong class file.

Thanks for your help,

Willa 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
Markus Schaber
Sent: Monday, November 21, 2005 2:48 PM
To: PostGIS Users Discussion
Cc: Paul Ramsey
Subject: Re: [postgis-users] RE: JDBC - Error in the user document

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
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





More information about the postgis-users mailing list