[postgis-users] JDBC retrieve geometry object: how to?

Pedro Salazar pedro-b-salazar at ptinovacao.pt
Tue Apr 8 10:30:42 PDT 2003


On Tue, 2003-04-08 at 18:01, Paul Ramsey wrote:
> On Tuesday, April 8, 2003, at 09:42 AM, Pedro Salazar wrote:
> 
> > Hi Paul,
> >
> > shouldn't the addDataType be also in the PGConnection interface? (For
> > now I will cast it to AbstractJDBC1Connection instead of the
> > PGConnection)
> 
> Don't cast it at all. Perhaps I am misunderstanding the JDBC layout,  
> but I suspect that all the functions on the Abstract* classes should be  
> visible on the normal JDBC connection object.
> >

I think there could be a misunderstood here:

If I don't cast, I would be able to see only the interface
java.sql.Connection or the interface org.postgresql.PGConnection, which
the last one, in postgresql 7.3.2 hasn't the addDataType method - I
think it could be an oversight in the release. Otherwise, only the
default types would be mapped in AbstractJDBC1Connection.

> > BTW, if I intend to return my geometry object from a postgresql
> > function, what type should declare in my function to wrap my postgis
> > object, and what type my function would return?
> 
> We don't have serverside casts from the PostGIS types to PgSQL types.  
> The PgSQL types are not rich enough to support the information in the  
> PostGIS types (hence, PostGIS).

OK, you have a point, but even than I think it would make sense a way to
convert both type, even with loss of features, because postgresql type
would always exist in the database.

Meanwhile, I find a workaround here. I return in my pgsql function a
text type (--> AsText(geom)), and in the java side, I build my geometry
using the constructor PGgeometry(String).

thanks,
Pedro Salazar.
-- 
PS
pedro-b-salazar at ptinovacao.pt
PGP:0E129E31D803BC61




More information about the postgis-users mailing list