• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

question about the update

 
Jofer Chan
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,everyone:
in the client,I book a record,the recNo and data passed to the server,
the server use the DBAccessImpl class to call the Data class,
in the Data class,the updateRecord method define follow:

my question is:
1. in the client,the record don't have the lockCookie,now ,it (the record) passed to the server,Does make the lockCookie with Random.nextLong() for this record in the DBAccessImpl class,then passed into the Data's updateRecord method?
2.in the Data's updateRecord method,it throw the SecurityException,
but access the file use the lock() -> updateRecord() -> unlock() mechanism,
in lock() throw the SecurityException,why does throw the SecurityException in the updateRecord method again?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jofer,

1. in the client,the record don't have the lockCookie,now ,it (the record) passed to the server,Does make the lockCookie with Random.nextLong() for this record in the DBAccessImpl class,then passed into the Data's updateRecord method?

The lock() method returns the lockCookie which the client can then use in the update() method.

2.in the Data's updateRecord method,it throw the SecurityException,
but access the file use the lock() -> updateRecord() -> unlock() mechanism, in lock() throw the SecurityException,why does throw the SecurityException in the updateRecord method again?[/QB]


The SecurityException will occur if a client tried to bypass the call to lock(). So if a client tried to call updateRecord() without having first called lock() then the client will not have a lockCookie, and any value it tries to pass as the lockCookie will not match any value in the collection of locked records (even assuming the record is currently locked). So if a client tries to update a record without locking it first, you will throw the SecurityException from the updateRecord() method.
Regards, Andrew
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic