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?
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.
I strongly recommend fixing the connection leak in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With