Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id A520A2E0041 for ; Tue, 19 Feb 2008 04:46:44 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 28762-08 for ; Tue, 19 Feb 2008 04:46:41 -0400 (AST) Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id DA86C2E003E for ; Tue, 19 Feb 2008 04:46:40 -0400 (AST) Received: from 219-89-100-120.jetstart.xtra.co.nz ([219.89.100.120] helo=[192.168.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1JRO7V-0007Rw-G5; Tue, 19 Feb 2008 21:46:33 +1300 Message-ID: <47BA976E.9030004@opencloud.com> Date: Tue, 19 Feb 2008 21:46:38 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Till Toenges CC: Tom Lane , Gregory Stark , PostgreSQL - JDBC Subject: Re: Implementing setQueryTimeout() References: <47B8E200.2020307@opencloud.com> <5350.1203299903@sss.pgh.pa.us> <47B8EB1C.8090802@opencloud.com> <87ejbao6bg.fsf@oxford.xeocode.com> <47BA2A6E.6050907@opencloud.com> <17814.1203384054@sss.pgh.pa.us> <47BA470A.8000904@opencloud.com> <47BA9284.5050407@kyon.de> <47BA92EA.1070201@opencloud.com> <47BA95D5.40408@kyon.de> <47BA9626.5060209@opencloud.com> In-Reply-To: <47BA9626.5060209@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/146 X-Sequence-Number: 18353 Oliver Jowett wrote: > Till Toenges wrote: >> Oliver Jowett wrote: >>>> A network timeout or anything worse is handled in an entirely >>>> different part of the code. That is not the responsibility of the >>>> driver, and doesn't event need to be part of the database related >>>> code at all. >>> >>> I'm not sure what you mean here - if the connection to the DB fails, >>> the driver will certainly handle that and tell you about it via a >>> SQLException! >> >> Sorry. Of course the driver must handle failed connections. I meant >> the code in my application, which handles the two cases (timeout but >> usable connection vs broken connection for whatever reason) differently. > > You can check the SQLState of any exception thrown to tell the > difference, right? Just to clarify: - If the soft query timeout goes off and the server cancels the query, you will get a server-generated SQLException saying the query was cancelled. This will be some non-fatal SQLState and generally looks like any other SQL error generated by the server. The connection and statement will still be live (and in fact IIRC the transaction is still live and you can rollback to a savepoint, etc, if you like) - If the hard query timeout goes off, you will get a SQLException generated by the driver that has whatever the SQLState for connection errors is (I can't remember offhand) - but it will look very similar to the exception you get for any other connection problem when running a query. Basically the "hard query" timeout just introduces a new cause of connection errors - "server didn't respond within the timeout". It will otherwise behave like any other network-level connection error. -O