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 3F9A43A5456 for ; Mon, 24 Jan 2005 09:55:48 +0000 (GMT) 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 80591-06 for ; Mon, 24 Jan 2005 09:55:36 +0000 (GMT) Received: from relay.ie-online.it (mercurio.ie-online.it [193.27.202.38]) by svr1.postgresql.org (Postfix) with ESMTP id 247983A5442 for ; Mon, 24 Jan 2005 09:55:37 +0000 (GMT) Received: from [192.168.0.95] (unknown [192.168.0.95]) by relay.ie-online.it (Postfix) with ESMTP id 4F76248E40D; Mon, 24 Jan 2005 10:55:37 +0100 (CET) Message-ID: <41F4C6A4.7000309@ie-online.it> Date: Mon, 24 Jan 2005 10:57:56 +0100 From: Daniele Bufarini User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050103 X-Accept-Language: en-us, en, it MIME-Version: 1.0 To: Kris Jurka Cc: pgsql-jdbc@postgresql.org Subject: Re: [S] Re: Problems with non scrollable cursors References: <41F12F29.5010602@ie-online.it> <41F4B798.60408@ie-online.it> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.29.0.5; VDF: 6.29.0.52; host: relay.ie-online.it) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/227 X-Sequence-Number: 12107 Kris Jurka wrote: >On Mon, 24 Jan 2005, Daniele Bufarini wrote: > > > >>Actually using the cursor multiple time is what I was thinking... >>In fact, I can keep an open database connection only for large result >>set and use a one time connection for all the others. >>My problem is that I cannot scroll back using a cursor... I'm wondering >>If I have to modify the jdbc driver or the back end or if there are >>other solutions, less time consuming... >> >> > >The easiest thing to do is to forgo parts of the JDBC interface and do it >manually. > >Statement.execute("DECLARE mycursor SCROLL CURSOR FOR ..."); > >Then: > >Statement.execute("MOVE ABSOLUTE 2000 IN mycursor"); >ResultSet = Statement.executeQuery("FETCH FORWARD 10 FROM mycursor"); > > >To fix this in the driver there are two avenues of attack here. The 7.4 >driver used explicit DECLARE and FETCH calls for cursors. The driver >would need to be modified to add a SCROLL keyword and then handle moving >back and forth. A patch was produced to do this, which I had some >concerns about, that the poster never responded to: > >http://archives.postgresql.org/pgsql-jdbc/2004-05/msg00164.php > >The 8.0 driver has been changed to use protocol level portals which are >pretty much the same as cursors. The problem is that protocol only >has support for forward cursors in both declaration and fetching. To fix >things along these lines would require pretty much all of the work in the >driver as the 7.4 path, but would also require some backend work and more >importantly, convincing people to change the frontend/backend protocol. > Thank you very much for your explanations, Kris! First I'll try to use cursors without the JDBC interface: If that shouldn't work as required, I'll consider the two other avenues of attack. I'll let you know... Best regards, Daniele Bufarini.