Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aCjmy-00074S-Dj for pgsql-jdbc@arkaria.postgresql.org; Sat, 26 Dec 2015 08:01:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aCjmx-0003vt-H6 for pgsql-jdbc@arkaria.postgresql.org; Sat, 26 Dec 2015 08:01:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aCjmR-0003LU-Ih for pgsql-jdbc@postgresql.org; Sat, 26 Dec 2015 08:00:47 +0000 Received: from xs.dms.at ([78.142.176.1]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aCjmN-0006T0-BL for pgsql-jdbc@postgresql.org; Sat, 26 Dec 2015 08:00:46 +0000 Received: from localhost (unknown [127.0.0.1]) by xs.dms.at (Postfix) with ESMTP id ACE383C427; Sat, 26 Dec 2015 08:00:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at dms.at Received: from xs.dms.at ([127.0.0.1]) by localhost (mainsrv.dms.at [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 51Wa6zqh7h8L; Sat, 26 Dec 2015 09:00:40 +0100 (CET) Received: from [192.168.191.106] (hacheni.kopileft.com [192.168.191.106]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by xs.dms.at (Postfix) with ESMTPSA id 47D9735897; Sat, 26 Dec 2015 09:00:40 +0100 (CET) Message-ID: <567E493D.7050204@kopileft.com> Date: Sat, 26 Dec 2015 09:01:01 +0100 From: =?UTF-8?B?SMOpZGkgSEFDSEVOSQ==?= User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: Vladimir Sitnikov CC: List Subject: Re: JDBC and positioned updates References: <567D5C7B.3060402@kopileft.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------010107010803030201010707" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------010107010803030201010707 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, We cannot use the updatable result set technique since we support multiple databases so we want to use the AINSI syntax with the CURRENT OF cursor_name. We tried to implement the java.sql.Statement#*setCursorName*(String) and the java.sql.ResultSet#*getCursorName*() methods so that we can set the cursor name of an SQL statement. But, it seems to be more complicated than that we expected since the database server always says *"cursor "name" does not exist**" *What we did is to change a little bit the implementation of the *org.postgresql.core.v3.QueryExecutorImpl *in a way that we can define a cursor name for an SQL statement. We tried to inject this in the *org.postgresql.core.v3.Portal *class but we did not succeed. Any ideas ? Best regards On 12/25/2015 04:38 PM, Vladimir Sitnikov wrote: > 1) Have you considered using "updatable ResultSet"? > > Here's a sample: > https://github.com/pgjdbc/pgjdbc/blob/32f513370306529005cb36d968f8e415f4a88aec/pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpdateableResultTest.java#L301-L303 > > 2) > WHERE CURRENT OF cursor_name > > ResultSet implementation fetches result rows in batches, thus "current > of" at the database side might point to a slightly different row than > ResultSet at the java side. > > 3) You do not expect high throughput of that kind of API, do you? > Updatable ResultSet is not using batching, so each update would result > in a database roundtrip. > > Vladimir --------------010107010803030201010707 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hi,

We cannot use the updatable result set technique since we support multiple databases so we want to use the AINSI syntax with the CURRENT OF cursor_name.

We tried to implement the java.sql.Statement#setCursorName(String) and the  java.sql.ResultSet#getCursorName() methods so that we can set the cursor name of an SQL statement. But, it seems to be more complicated than that we expected since the database server always says  "cursor "name" does not exist"

What we did is to change a little bit the implementation of the org.postgresql.core.v3.QueryExecutorImpl in a way that we can define a cursor name for an SQL statement. We tried to inject this in the org.postgresql.core.v3.Portal class but we did not succeed.

Any ideas ?

Best regards

On 12/25/2015 04:38 PM, Vladimir Sitnikov wrote:
1) Have you considered using "updatable ResultSet"?

Here's a sample:
https://github.com/pgjdbc/pgjdbc/blob/32f513370306529005cb36d968f8e415f4a88aec/pgjdbc/src/test/java/org/postgresql/test/jdbc2/UpdateableResultTest.java#L301-L303

2) >   WHERE CURRENT OF cursor_name

ResultSet implementation fetches result rows in batches, thus "current
of" at the database side might point to a slightly different row than
ResultSet at the java side.

3) You do not expect high throughput of that kind of API, do you?
Updatable ResultSet is not using batching, so each update would result
in a database roundtrip.

Vladimir

--------------010107010803030201010707--