get row count from a "cursor resultset" - Mailing list pgsql-jdbc

From Maik Wiege
Subject get row count from a "cursor resultset"
Date
Msg-id 42CC2EB6.8020505@gmx.de
Whole thread Raw
Responses Re: get row count from a "cursor resultset"  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Hello!
I'm querying my database and sometimes get a very big resultset back, so
I needed to use a resultset with a cursor to avoid a OutOfMemoryError.

Now, because I have to use a TYPE_FORWARD_ONLY resultset for that, I can
not use the result.last() function anymore to retrieve the amount of
rows the query returns.

The query is a little bit complicated and that for can take some time,
so I don't want to do the "SELECT COUNT(*) FROM (SELECT...)" afterward,
what would result in doing the query twice and there for would double
the time needed.

I didn't find a solution for this, but there must be, because the
pgAdmin III - tool does this. After starting the query in the SQL-Dialog
it asks wether to retrieve just the first 100 results or all results
displaying the corect amount of found rows. Or is this just not possible
with jdbc.

Thanks for any help

   Maik

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: JDBCCTS issues
Next
From: Oliver Jowett
Date:
Subject: Re: get row count from a "cursor resultset"