Discussion:
Closing all existing PostgreSQL database connections
(too old to reply)
Norbert Radyk
2007-05-07 07:10:45 UTC
Permalink
Hi,

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?

Regards, Norbert


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
Heikki Linnakangas
2007-05-07 10:32:04 UTC
Permalink
Post by Norbert Radyk
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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match
Loading...