File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes App doesn't always close out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "App doesn Watch "App doesn New topic
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: 24183
    
  34

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...
[ August 16, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: App doesn't always close out
 
Similar Threads
Exit an GUI application
How to close this window?
Repainting inside loop that uses sleep method
applets
App doesn't always close out