I've been dealing with an issue that involves only allowing a single user to access certain data at a time. The reason for this is so that more than one user can't be editing the data at once.
My current solution is as follows: a user opens the data in a GUI (java) -> a value in the mysql table is set to "currently being viewed" for the data. This way, if another user tries to view the data, it will know there is someone currently editing it.
The problem arises when the user is done with editing the data. Normally, they would click "Done" and the mysql value would change back to "available". However, what if the program is forced shut, or if the user loses power?
How should I notify the program or the mysql table in this case that the data should be available again?
I currently use a WindowClosing event but it doesn't work if the program is forced closed.