aspose file tools*
The moose likes Beginning Java and the fly likes Update a DB if JVM closes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Update a DB if JVM closes." Watch "Update a DB if JVM closes." New topic
Author

Update a DB if JVM closes.

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Okay,
I've solved two of three issues with a db dependant app that I wrote.
When a user is no longer using the app the database flags there ID with an 'N' in a field of the DB.
It works if they Exit the app with button I've created, or if the use the "X" to close the window via the file systems method.
What do I do if the user just shuts down the machine therefore leaving it up to the JVM to exit the app?
How can I get the app to update the DB with the 'N' flag?


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Corey McGlone
Ranch Hand

Joined: Dec 20, 2001
Posts: 3271
By no means am I a Java GUI master, but you might want to check out the windowClosed method of the WindowListener interface. This may get called any time the application is terminated.
Corey


SCJP Tipline, etc.
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I'll give that a shot...
thanx...
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Well,
That didn't seem to work.
What I am trying to avoid is the user shutting down the machine without exiting the application first.
If they don't exit the application, their "active" status doesn't get changed.
When they first sign into it the "active" flag gets set to "Y". When the app closes, it should set the "active" flag to "N".
If they just shut downt he machine leaving the closing to the JVM, the update never happens.
Is there a way to ensure that change occurs?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update a DB if JVM closes.