[postgis-users] How do I handle a ResultSet from a java request?

Andrew Davis drsockmonkee at gmail.com
Tue Oct 6 06:32:39 PDT 2015


Hi all..

I'm sending my first question out so patience please.

I've got a working servlet on my server that will query for and get
information back from my postgis DB.

Up until now I have been just parsing the results and sending back a json
string.  I want to get a GeoJSON back from my db now.

I've been working through the information I found here:

http://www.postgresonline.com/journal/archives/267-Creating-GeoJSON-Feature-Collections-with-JSON-and-PostGIS-functions.html

I can create the table with locations included and a geog value, and I can
run the query below

SELECT row_to_json(fc)
 FROM ( SELECT 'FeatureCollection' As type,
array_to_json(array_agg(f)) As features
 FROM (SELECT 'Feature' As type
    , ST_AsGeoJSON(lg.geog)::json As geometry
    , row_to_json((loc_id, loc_name)) As properties
   FROM locations As lg   ) As f )  As fc;


which brings back a single line string and is in the correct format
all in PGAdmin3.


I have been trying to duplicate this from my server with java and am
stuck at the point where I have

run the query and have a 'thing' (ResultSet) but am unsure as to how
to handle it and then pass it

back to the client.


Any help would be welcome.


Andy..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20151006/b0d92875/attachment.html>


More information about the postgis-users mailing list