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 BB028329E46 for ; Sat, 18 Sep 2004 22:51:08 +0100 (BST) 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 45503-04 for ; Sat, 18 Sep 2004 21:51:02 +0000 (GMT) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by svr1.postgresql.org (Postfix) with ESMTP id 2994A329C7B for ; Sat, 18 Sep 2004 22:51:02 +0100 (BST) Received: from [192.168.1.52] (dtenny.ne.client2.attbi.com[24.60.112.224]) by comcast.net (rwcrmhc12) with ESMTP id <2004091821510101400fddhpe>; Sat, 18 Sep 2004 21:51:01 +0000 Message-ID: <414CADC3.5050907@comcast.net> Date: Sat, 18 Sep 2004 17:50:59 -0400 From: Jeffrey Tenny User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: "Idle in Transaction" revisited. Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/109 X-Sequence-Number: 10999 > John R Pierce , pgsql-jdbc@postgresql.org > > Gaetano Mendola wrote: > >> John R Pierce wrote: >> >>> I'm curious what common practice is for threads that do nothing >>> but SELECTS... do folks just enable auto_commit, thereby >>> preventing pgJDBC from doing BEGIN; ? Do they lace their code >>> with COMMIT() calls? >> >> >> >> We were bitten by this problem too, and my solution was to suggest >> our developer to do and explicit: "ABORT" after the connection, and >> do explicit "BEGIN" "END" instead of rely on the jdbc interface. >> > > > This is a pretty bad idea as it can confuse the driver's idea of the > current transaction state. For example, cursor-based resultsets won't > ever be used if you do your own transaction demarcation in this way. > > Better to use the standard JDBC autocommit API and a driver that has > the premature-BEGIN problem fixed. Second that, it's a very bad idea. I once naively had my own transaction management using begin/end via jdbc for multi-statement transactions against PostgreSQL. Then the driver was updated at some point and I was getting all kinds of screwed up commit logic and inconsistent data models. Stick with and support the proper JDBC interfaces. Anything else is platform dependeng, among other bad things.