Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 118C99FB2FF for ; Mon, 7 May 2007 07:32:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 59196-07 for ; Mon, 7 May 2007 07:32:31 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.235]) by postgresql.org (Postfix) with ESMTP id EE99A9FB2F5 for ; Mon, 7 May 2007 07:32:31 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id i28so1301501wxd for ; Mon, 07 May 2007 03:32:31 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=b20oXgpowo4K31O55LyJx9A4Z4kNoCn0Uvh2tTlaxNcDDad68Z+SPUpNd/2JeksPkdQ9SJDKRiQVZyOmeMTzOlIVtXjPUlX0suH5R/a0P+KbTNG0C5wO0prnhwM8oWCx6Jos7P7CbKQBPxWsxonyHuGFCSLZOGlj5CmfdmSl2Xc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=XlMPumB6VlX9hUeEBqZO0C+qJFAxmFTwPyMSQxa8PnZ8r3RfFnUBR6Xa9SbqkCdk11qeEjrdfS5cBBzHk1TYqT2D4TpB3I1FSdowl77kMtsuT8+8cZsJxGHGcnii3AvL70H9H+9ztvtQbOHmJ/YRrAtf1TIx3uZtLjEl0RabOnA= Received: by 10.70.72.11 with SMTP id u11mr11499376wxa.1178533950019; Mon, 07 May 2007 03:32:30 -0700 (PDT) Received: from ?192.168.1.34? ( [82.3.70.100]) by mx.google.com with ESMTP id h20sm12927526wxd.2007.05.07.03.32.27; Mon, 07 May 2007 03:32:29 -0700 (PDT) Message-ID: <463F0024.2060701@enterprisedb.com> Date: Mon, 07 May 2007 11:32:04 +0100 From: Heikki Linnakangas User-Agent: Icedove 1.5.0.10 (X11/20070329) MIME-Version: 1.0 To: Norbert Radyk CC: pgsql-jdbc@postgresql.org Subject: Re: Closing all existing PostgreSQL database connections References: <9810300235.20070507091045@wp.pl> In-Reply-To: <9810300235.20070507091045@wp.pl> 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: 200705/20 X-Sequence-Number: 17010 Norbert Radyk wrote: > I've got a question about PostgreSQL JDBC API. Is there any way to > close all existing & open connections to the particular database. I > mean the connections made by some external programs too. > > I simply need to drop the database to which there are some open > external connections. I cannot get the java.sql.Connection object in > order to close the connection, but maybe there is some other way to do > this? Unfortunately there's no supported way to terminate individual backends. From command line, you can use "kill" to do that, but it's not a very well-tested codepath and it's not officially supported. IOW, not recommended on production servers. There's also a tool called "cutter", which let's you terminate any TCP/IP connection: http://www.lowth.com/cutter/. I've never used that myself, but it seems like a safe option. The easiest option is to just restart postmaster. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com