[postgis-users] JDBC retrieve geometry object: how to?
Paul Ramsey
pramsey at refractions.net
Tue Apr 8 10:01:52 PDT 2003
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.
>
> 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).
Paul
> thanks,
> Pedro Salazar.
>
> On Tue, 2003-04-08 at 17:13, Paul Ramsey wrote:
>> Try doing the addDataType without the typecast first. It looks like
>> the
>> JDBC implementation changed between 7.2 and 7.3. If you read the
>> source
>> (Luke) you'll find that addDataType still exists, but it is now part
>> of
>> the AbstractJDBC1Connection object, so you might be able to call it
>> directly on the connection.
>>
>> P
>>
>> On Tuesday, April 8, 2003, at 07:58 AM, Pedro Salazar wrote:
>>
>>> Greetings,
>>>
>>> I'm trying to get a geometry from the database through JDBC. I read
>>> the
>>> documentation but I think it's not actualized - there isn't any
>>> org.postgresql.Connection object but a org.postgresql.PGConnection
>>> that
>>> hasn't any such method as adddataType().
>>>
>>> Example from POSGIS documentation:
>>> ---
>>> ...
>>> ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis
>>> .P
>>> Ggeometry");
>>> ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PG
>>> bo
>>> x3d");
>>>
>>> Statement s = conn.createStatement();
>>> ResultSet r = s.executeQuery("select AsText(geom) as geom,id from
>>> geomtable");
>>> while( r.next() ) {
>>> PGgeometry geom = (PGgeometry)r.getObject(1);
>>> ...
>>> ---
>>>
>>> How could I retrieve a geometry from a postgresql (7.3.2) database
>>> with
>>> postgis 0.7.4?
>>>
>>> thanks,
>>> Pedro Salazar.
>>>
>>> --
>>> PS
>>> pedro-b-salazar at ptinovacao.pt
>>> PGP:0E129E31D803BC61
>>>
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>> Paul Ramsey
>> Refractions Research
>> Email: pramsey at refractions.net
>> Phone: (250) 885-0632
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> --
> PS
> pedro-b-salazar at ptinovacao.pt
> PGP:0E129E31D803BC61
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
Paul Ramsey
Refractions Research
Email: pramsey at refractions.net
Phone: (250) 885-0632
More information about the postgis-users
mailing list