Hi ranchers, When i planned to write update method, i confonted the lockCookie parameter. I only know that parameter refer to lock designing either in client or server.Here I show you the instruction from my assignment:
// Modifies the fields of a record. The new value for field n // appears in data[n]. Throws SecurityException // if the record is locked with a cookie other than lockCookie. public void update(int recNo, String data, long lockCookie) throws RecordNotFoundException, SecurityException;
Isn't it against certification rules to ask that kind questions here?!?
Nope. We have had (and continue to have) discussions with Sun as to what is appropriate on this site and what we are allowed to have in the various forums. Our understanding at this time is that these discussions are OK in the SCJD forum since, as developers, we would normally be expected to discuss problems with wording in projects, and discusss general techniques with other developers.
This is different from the SCEA forum, where the general concept is that architects are more likely to work alone on projects.
What we don't allow in this forum is having too much of a potential solution given away. So we dont allow large amounts of code to be posted, nor do we generally allow multiple methods of specific classes to be posted.
But Zhixiong's question is perfect for this forum (unfortunately I just got paged in the middle of this posting, or I would spend some time answering his question).
I think I answered this in another post to you but basically when your client wants to update a record, it must first call the lock method. This method will return a lock cookie to the client. The client must then pass this lock cookie as a parameter in the update and unlock methods. If the client does not pass the correct lock cookie then the update and unlock methods will not work (in fact they will probably through exceptions).