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 CF63A3A497E for ; Thu, 28 Oct 2004 21:02:07 +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 23992-06 for ; Thu, 28 Oct 2004 20:02:04 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 811A93A4978 for ; Thu, 28 Oct 2004 21:02:04 +0100 (BST) 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 (Exim 3.35 #1 (Debian)) id 1CNGSv-0001Eo-00; Fri, 29 Oct 2004 09:01:45 +1300 Message-ID: <41815066.1060308@opencloud.com> Date: Fri, 29 Oct 2004 09:02:46 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.8 (X11/20041021) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Giampaolo Tomassoni Cc: pgsql-jdbc@postgresql.org Subject: Re: Serializable transactions and SQLException References: <200410281711.21440.g.tomassoni@libero.it> In-Reply-To: <200410281711.21440.g.tomassoni@libero.it> X-Enigmail-Version: 0.86.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; 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: 200410/294 X-Sequence-Number: 11399 Giampaolo Tomassoni wrote: > Dears, > > I would like to develop java code using the pgsql-jdbc driver on serializable > isolated transactions. The (general) pgsql manual states that this, of > course, may cause concurrent updating transaction failures to inform the > client to retry the transaction as a whole. > > This is said to be reported by the error message: > > ERROR: Can't serialize access due to concurrent update > > > Great. I want to cope with it. But what's the SQLException.getSQLState() value > associated to this? Or is it a SQLException.getErrorCode()? Is this value > something 'standard', in the sense that, ie., if I need to switch to Oracle > it works fine? Is there a better way to identify 'please, retry' suggestions > than browsing the SQLException object? Your best bet is to use a 7.4 or later server and inspect the SQLState of the exception. To find out what SQLState to expect, either try it and see, or take a look at src/include/utils/errcodes.h in the server source tree and pair it up with the appropriate ereport() call you are interested in. For transaction serialization failures it is ERRCODE_T_R_SERIALIZATION_FAILURE which has a SQLState of 40001. SQLStates are somewhat standardized around SQL99. The comments in errcodes.h say: >> * The SQL99 code set is rather impoverished, especially in the area of >> * syntactical and semantic errors. We have borrowed codes from IBM's DB2 >> * and invented our own codes to develop a useful code set. I have no idea what Oracle does in this area. -O