| Author |
App doesn't always close out
|
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
|
|
Hi. I have an app I'm testing before sending it out to the users. I will run the app, and close out of it, by either pressing the exit button I have added, or clicking on the X in the JFrame. Usually when I do this, the DOS prompt will display "Press any key to continue" so I know it has closed out. Every once in a while, this message doesn't appear on the DOS prompt. When I look in task manager, the java.exe still shows as a process. This is the class I have that is supposed to close out the app, I have the above window listener added to the JFrame. Here is the code that runs when the exit button is pressed... Why doesn't the app always close out? I would say about 90% of the time, it closes OK, not sure what is happening to cause this. Any ideas?
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24050
|
|
Well, pretty clear that the call to DBConnection.closeConnection() is hanging. You could confirm this by pressing control-break in the DOS window the next time this happens - you should see a stack trace, and you should find this call in progress.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
|
|
Thanks for the reply. I tried doing a control-break in the DOS prompt, and it didn't do anything. I also removed the code that closes the connection to see if that is what was hanging, and ran the app again, and it still doesn't close out. What are some reasons why the close to the connection would be hanging? If it was the close statement hanging, why didn't it come back when I took out that code? Am I closing the connection the wrong way? It hangs everytime that I run the app now, only way to not get it to hang is to restart the PC. Also, right now, I am getting the (static)connection from the DB2connection class everytime I call a stored procedure. After getting my data, I am closing out the CallableStatement (I was told before the statement should close the result set so I didn't need to call close on the ResultSet as well), and I only call close on the acutal connection to the DB when the user exits the application. Is this correct, or should I close the connection to the DB after each stored procedure is called? Thanks again! [ August 16, 2003: Message edited by: Jennifer Sohl ] [ August 16, 2003: Message edited by: Jennifer Sohl ]
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
|
I'm moving this to The JDBC Forum...
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
Jennifer Sohl
Ranch Hand
Joined: Feb 28, 2001
Posts: 455
|
|
Hello! I was wondering if anyone had any more ideas on this issue. I would say the app is closing out about 60% of the time. I do a lot of testing, so I end up rebooting my pc a few times a day to get rid of all the 'java.exe' processes eating up my memory. I have tried to end the processes through task manager, but it tells me it cannot end the process. Access is denied. Thanks again for any help!
|
 |
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
|
What version of the JDK are you using? I noticed that this happened with 1.3 and 1.4.0 in Windows XP quite a bit. But I haven't had a single problem from 1.4.1 and 1.4.2.
|
 |
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
|
|
I also removed the code that closes the connection to see if that is what was hanging, and ran the app again, and it still doesn't close out. If you comment out everything that you have in windowClosing(), except System.exit(), would the problem still be there? If your app still doesn't exit, it means the event just doesn't fire.
|
 |
 |
|
|
subject: App doesn't always close out
|
|
|