Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CFBB7632746 for ; Tue, 18 May 2010 08:43:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 63393-04 for ; Tue, 18 May 2010 11:42:56 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by mail.postgresql.org (Postfix) with ESMTP id ABD56632297 for ; Tue, 18 May 2010 08:42:57 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 15B11AF36E; Tue, 18 May 2010 19:42:29 +0800 (WST) X-Virus-Scanned: Debian amavisd-new at postnewspapers.com.au Received: from mail.postnewspapers.com.au ([127.0.0.1]) by localhost (mail.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id IyDnhJxhCmAf; Tue, 18 May 2010 19:42:23 +0800 (WST) Received: from [10.1.1.7] (124-148-217-247.dyn.iinet.net.au [124.148.217.247]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Craig Ringer", Issuer "POST Certificate Authority" (verified OK)) by mail.postnewspapers.com.au (Postfix) with ESMTPSA id 3C530AF07E; Tue, 18 May 2010 19:42:23 +0800 (WST) Message-ID: <4BF27D11.8020001@postnewspapers.com.au> Date: Tue, 18 May 2010 19:42:09 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Rod CC: pgsql-jdbc Subject: Re: After server restart I get - An I/O error occured while sending to the backend. References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201005/44 X-Sequence-Number: 20528 On 18/05/2010 6:41 PM, Rod wrote: > Hi, > > I have simple JDBC client app running on Jetty. > Using 8.3 JDBC3 driver and PostgreSQL8.3 server running on localhost. > > Any time I restart the PostgresQL server I get SQL error: > An I/O error occured while sending to the backend. > > It appears that my application's connection to the server is not > re-established by some reason? Pooled connections usually don't get cleaned up until they're discovered to be dead. That happens when you try to use them and they break. Just be prepared for this to happen. If you get a bad connection, grab a new one and re-try your work. Yes, you can "test" the connection first ... but something might go wrong with it between testing it and starting to use it. You need to be prepared to handle failure at any point and re-try your work. Make sure to keep your work separated into clear units of work (wrapped as transactions) so you have a clear idea of what you're up to. > > I am no expert in JDBC. > First I was using plan JDBC. I thought that using DB connection pool > will automagically reconnect and solve this problem. > Switching to Apache commons DBCP did not change anything. > > What am I supposed to do to make it survive PostgreSQL server restart? It can't, just as it can't survive connection loss for other reasons. Your code must be prepared to deal with that. -- Craig Ringer