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

Andrew Davis drsockmonkee at gmail.com
Tue Oct 6 15:44:29 PDT 2015


Thanks for the help everyone..

It works..  I have a little bit of polishing up but it is printing out the
correct information.

The money portion ...

Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection(
"jdbc:postgresql://myserver/mydb", "user", "password");
st = con.createStatement();
//This has to be in a single line to work.
String myQuery = "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((ani_id, name,
lat, lon, animalpref)) As properties FROM animals As lg   ) As f )  As fc;";
rs = st.executeQuery(myQuery);
String returnValue = "";
while(rs.next()){
    String myResults = rs.getString(1);
  returnValue = myResults;
}
System.out.println(returnValue);


Andy

On Tue, Oct 6, 2015 at 3:21 PM, Andrew Davis <drsockmonkee at gmail.com> wrote:

> Thanks...  i will
> On Oct 6, 2015 3:21 PM, "Walter Nordmann" <walter.nordmann at web.de> wrote:
>
>> have a look at JDBC. thats's the right software library to use.
>>
>> Walter
>>
>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20151006/3f298335/attachment.html>


More information about the postgis-users mailing list