Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 962419FB7DD for ; Wed, 14 Feb 2007 02:11:30 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 33128-05 for ; Wed, 14 Feb 2007 02:11:23 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail63.csoft.net (leary.csoft.net [205.205.214.5]) by postgresql.org (Postfix) with SMTP id 4D3979FB7C7 for ; Wed, 14 Feb 2007 02:11:24 -0400 (AST) Received: (qmail 14301 invoked by uid 1112); 14 Feb 2007 06:11:22 -0000 Date: Wed, 14 Feb 2007 01:11:22 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Kevin Birkett cc: pgsql-jdbc@postgresql.org Subject: Re: Connection state after network failure? In-Reply-To: <346FF8985107AA41AC92CEC80E21E6B5BBC7@phxx05.exchange.phxx> Message-ID: References: <346FF8985107AA41AC92CEC80E21E6B5BBC7@phxx05.exchange.phxx> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=BAYES_50 X-Spam-Level: X-Archive-Number: 200702/53 X-Sequence-Number: 16609 On Fri, 9 Feb 2007, Kevin Birkett wrote: > I'm having a problem with our software which uses Postgres 7.2.3 and the > JDBC driver associated with it. In our code we only create one > connection to the database, and then use that connection as needed for > our DB interaction. The problem comes in when I simulate a network > failure (yank the cat5) after the app has started up and connected to > the remote database. I've tried an idea I found by searching the > archives of this mailing list, but I haven't been able to get it to > work. > > To me, if the connection loses its network connectivity, an exception > should be thrown here, and then I can handle it. However, what actually > happens is the system locks up on the call to execute and it never > throws and exception or a returns value (since the network is > unavailable). Am I missing something easy here? All I want to do is to > check whether or not the connection is valid and available. > TCP doesn't detect network failures immediately, hoping the network will be restored. If you wait long enough (on the order of an hour) you will get an Exception. You can adjust these settings globally via your OS or using a more recent postgresql version with tcp_keepalives_* here: http://www.postgresql.org/docs/8.2/static/runtime-config-connection.html Also get off the 7.2 release before it eats your data. Kris Jurka