Link to home
Start Free TrialLog in
Avatar of HKersten
HKersten

asked on

CLOSE_WAIT Process left on Database Server after Java program runs.

Even though I am closing my resultset, prepared statement, and database connection in the finally area of a try-catch, it is leaving a process on the database server that gets set to CLOSE_WAIT and then after about 3 hours goes to a LISTEN state and sits there until either the database is restarted or the PID killed. Why is this happening? What else do I need to do to tell the database server to get rid of that process? This is a problem because we only allow so many connections and after this program runs a 20 times, they are all taken up. This is a very simple Java program running on a Suse Linux server using JDBC against a Progress 10 database. Thanks for your help!
ASKER CERTIFIED SOLUTION
Avatar of jazzIIIlove
jazzIIIlove
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of HKersten
HKersten

ASKER

Thanks jazzIIIlove, I'll try removing the prepared statements and post back the results!
Thank you so much for your help! I wouldn't of guessed that it was the Prepared Statement cuasing this issue. You've saved me a bunch of time!
It was the Prepared Statements causing this issue. I switched them to Statement and now it works fine. Thanks!
but beware of sql injections...
Sorry, I was mistaken, that did not fix the issue. I had some LISTEN processes still on the database server and apparently they were from the script running before so when I changed to statements and re-ran, it didn't create another process. If one is out there, it doesn't create another one. So it must have something to do with caching the process but I don't know why. Please let me know if you have any other suggestions.
Hi there;

I am not sure that will work and it's a bad practice but well, let's assign the statements to null after closing them...
or

if you using linux:
a batch:
ps -Ao pid,command | grep java | grep eclipse
or:
kill -9 `pidof process_name`
replacing process_name by the name of process you want to kill
or:

a java code to kill process:
http://www.koders.com/java/fid4E9CF0CCE742471D5F25669CB19F951B2B0F454D.aspx

or:
https://www.experts-exchange.com/questions/23703468/what-is-kill-3-on-java-process-id.html

Best regards...
You can take the points back i guess if you want...

I don't mind...since your question is not yet solved...By the way, you debug the code?