• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update a DB if JVM closes.

 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll give that a shot...
thanx...
 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic