Skip site navigation (1) Skip section navigation (2)

Re: No. of rows on result set

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Dianne Yumul <dianne(at)wellsgaming(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: No. of rows on result set
Date: 2005-07-15 00:10:55
Message-ID: 42D6FF0F.1020102@opencloud.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Dianne Yumul wrote:
> Hello List,
> 
> Recently upgraded to Postgresql 8.0.3, JDBC Driver 8.0 Build 311 and
> realized that I can no longer use the last() method for ResultSet
> because of the default TYPE_FORWARD_ONLY.

Right, you're not meant to use last() on TYPE_FORWARD_ONLY per the JDBC
spec, and the driver implementation now means we can't support it..

> Several of our apps use this
> to find the number of rows on a result set. Looking at the archives, my
> options would be to (1) do a separate SELECT COUNT(*) . . ., (2) change
> result set type to TYPE_SCROLL_INSENSITIVE, (3) replace arrays with
> something else that will not require the size of the result set, or (4)
> a better solution I haven't thought of : ).

If you need to use last(), then TYPE_SCROLL_INSENSITIVE is the way to go.

Note that this means the driver will retrieve the entire resultset in
one go rather than possibly using cursors (if you've set fetchsize and
have autocommit off) -- you might have problems with big resultsets. If
so I'd go with COUNT.

-O

In response to

Responses

pgsql-jdbc by date

Next:From: Csaba NagyDate: 2005-07-15 08:12:27
Subject: Re: Using a 7_4 JDBC driver to connect to 8.0
Previous:From: Oliver JowettDate: 2005-07-15 00:07:00
Subject: Re: Using a 7_4 JDBC driver to connect to 8.0

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group