Hi all, I have a Java GUI Application which has a Db connection. Now when the application window is closed using the normal 'X' button on the top right corner,I can catch the WindowClosing event and close the db connection. But since the application is running from a dos prompt,I can even close it using a Ctrl C. Is there any way for me to catch the Ctrl C and the take appropriate action like closing the open db connections? Thanks in advance, Chinmay.......
The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
You don't clean up. But you could put some start up code that would try to fix what was not properly released during the last running of the application. This could be rebuilding logs or reporting on last state of the application. However, outside of using a UPS, there is no such thing as a "Loss of Power Exception or Event"
Hope This Helps
Joined: Apr 14, 2003
My point exactly. Which is why I don't think it's a good practice to trap Ctrl-C. What if the user does an "end task" in Windows, or "kill -9" in UNIX... or the network dies... or a hard disk crashes. There are just too many possibilities. It makes better sense to do damage control either on the server side, or while starting up as Rodney ponted out.
Joined: Dec 08, 2001
Point accepted Nilesh! But when u r working on a single db connection,u have to try and plug as many ambuities as u can. Thanks, Chinmay