Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Philippe EMERIAUD <p(dot)emeriaud(at)ordirope(dot)fr>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE
Date: 2015-03-06 17:51:19
Message-ID: CADK3HHKJivh_Jcpeo1OvX+YcJAco0A-Gg7eY_8yqd5ZZCQC42g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Can you point me to the source of that quote ?

The documentation here
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html does not
specify anything about ResultSet closing, or completion ?

Short version is that the driver does not hold the lock past the return of
the result set, so unfortunately not.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 6 March 2015 at 11:27, Philippe EMERIAUD <p(dot)emeriaud(at)ordirope(dot)fr> wrote:

> Hi all,
> We have an application based on DB2 database, We are testing this same
> application on PostgreSQL database. By default we are in autocommit on mode.
> On DB2 (and Oracle), the query SELECT FOR UPDATE locks the row until the
> resultset is closed. On PostgreSQL database (all versions) this same query
> never locks (because we are in autocommit on mode). But this is a bad
> implementation of JDBC specification : "If a connection is in auto-commit
> mode, then all its SQL statements will be executed and committed as
> individual transactions.[...] The commit occurs when the statement
> completes or the next execute occurs, whichever comes first. In the case of
> statements returning a ResultSet object, the statement completes when the
> last row of the ResultSet object has been retrieved or the ResultSet object
> has been closed."
> Is it possible to lock row in autocommit on mode on PostgreSQL database ?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Landry 2015-03-06 18:11:45 pg_upgrade failing from 9.3 to 9.4 because "template0" already exists
Previous Message Adrian Klaver 2015-03-06 17:41:54 Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE

Browse pgsql-jdbc by date

  From Date Subject
Next Message Thomas Kellerer 2015-03-06 18:31:36 Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE
Previous Message Adrian Klaver 2015-03-06 17:41:54 Re: Problem JDBC, AutoCommit ON and SELECT FOR UPDATE