Dinesh Dabhi
Dinesh Dabhi

Reputation: 856

How to close the all ports opened by postgres?

I am using PostgreSQL database in the JSP website.

Somewhere my connection is not closed in code. So port was opened by the PostgreSQL was remained in ESTABLISHED situation and remained in that state only.

After sometime number of ports exceeds the limit of PostgreSQL total limit and than I have to manually restart the PostgreSQL from Linux by,

service PostgreSQL restart

Is there any way to delete all the ports opened by PostgreSQL through JAVA file?

Upvotes: 3

Views: 776

Answers (2)

Tim Lamballais
Tim Lamballais

Reputation: 1054

I strongly recommend fixing the connection leak in your code.

Upvotes: 1

jcern
jcern

Reputation: 7848

Take a look at the pg_cancel_backend() function: http://www.postgresql.org/docs/8.2/static/functions-admin.html

However, you should consider trying to fix the unclosed connections in your code as you are likely to run into memory issues and other strangeness.

Upvotes: 3

Related Questions