![]() | |
#11
| |||
| |||
|
|
[...] I am now locking database records when the user stars to modify them, so no other user can do the same thing until they're free again. [...] There's two common ways of handling this: a sloppy and easy way, and a clever, powerful way that's a lot more work. The easy, sloppy way is to have a marker set on the record when someone opens up the record for editing so that anyone that comes along later and also opens the record, they get a little alert box [...] The clever and lot of work way keeps a copy of the record as it originally was when loading the data for working. You don't need to notify anyone else until such time as the user tries to save the record, at which point it goes through all the relevant columns, and looks for values that are NOT the same as in the orignal record [...] Where there's conflicts, ask the user what to do. |
#12
| |||
| |||
|
|
[...] have a locked_time and a locked_by attribute in the table, and a thread that touches the lock say every 10 seconds (and commits each touch immediately). Another user can take over the lock if it's locked by himself or older than say 30 seconds, because that means something bad happened to the client holding the lock. [...] |
|
[...] There are other possible variants as well. Example: begin transaction select row_1 end transaction do edit in client begin transaction select row_2 if row_1 == row_2 update row commit else <inform user rollback |
|
end |
#13
| |||
| |||
|
|
Peter H. Coffin wrote: There's two common ways of handling this: a sloppy and easy way, and a clever, powerful way that's a lot more work. The easy, sloppy way is to have a marker set on the record when someone opens up the record for editing so that anyone that comes along later and also opens the record, they get a little alert box [...] I will try to combine the two methods: [...] |
#14
| |||
| |||
|
|
On 2010-09-21 16:38, enos76 wrote: [...] Hello Peter, thank you for your interest in my issue. You got me there! I am indeed locking records indefinitely (BEGIN; SELECT ... WHERE ... FOR UPDATE while the user enters data. I feelguilty for what I'm doing, and it may be too late to change design. Here is the scenario: I was told to build a networked application with Java and Mysql, without using a WEB server or any other client-server architecture. I did express my perplexity, but the boss insisted, so the project started. Java Swing and MySQL through JDBC. I am now locking database records when the user stars to modify them, so no other user can do the same thing until they're free again. The only alternative I can see with the limitations the management put, is to dedicate database tables to the only purpose of locking records. Your basic options are a "checkout" system or a "resolve conflict" |
#15
| |||
| |||
|
|
Your basic options are a "checkout" system or a "resolve conflict" system. [...] Is this really a "networked application", where you have a constant open connection to a client program you control, or is this something where the client is a browser making HTTP requests? |
![]() |
| Thread Tools | |
| Display Modes | |
| |