Solved

CLOSE_WAIT Process left on Database Server after Java program runs.

Posted on 2008-10-28
8
544 Views
Last Modified: 2013-12-20
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!
0
Comment
Question by:HKersten
  • 4
  • 4
8 Comments
 
LVL 12

Accepted Solution

by:
jazzIIIlove earned 500 total points
ID: 22821776
Hi there;

Maybe the problem is in PreparedStatement...

PreparedStatement  the statement is cached and then the execution path is pre determined on the database server allowing it to be executed multiple times in an efficient manner...

But i am not sure...

Best regards...
0
 

Author Comment

by:HKersten
ID: 22821802
Thanks jazzIIIlove, I'll try removing the prepared statements and post back the results!
0
 

Author Closing Comment

by:HKersten
ID: 31510731
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!
0
 

Author Comment

by:HKersten
ID: 22822291
It was the Prepared Statements causing this issue. I switched them to Statement and now it works fine. Thanks!
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22822314
but beware of sql injections...
0
 

Author Comment

by:HKersten
ID: 22822565
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.
0
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22822701
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:
http://www.experts-exchange.com/OS/Unix/Q_23703468.html

Best regards...
0
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22822718
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?
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 80
Basic Java Case or If-Else statement... 3 43
Java SE 8u111  Lot of stuff broke 11 54
use lov values 2 33
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now