X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BABBE52C71 for ; Thu, 14 Jul 2005 21:11:01 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32365-10 for ; Fri, 15 Jul 2005 00:10:54 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 0F48252C6C for ; Thu, 14 Jul 2005 21:10:53 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DtDn5-00061D-TK; Fri, 15 Jul 2005 12:10:55 +1200 Message-ID: <42D6FF0F.1020102@opencloud.com> Date: Fri, 15 Jul 2005 12:10:55 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dianne Yumul Cc: pgsql-jdbc@postgresql.org Subject: Re: No. of rows on result set References: In-Reply-To: X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/92 X-Sequence-Number: 13240 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