• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lock(-n) e.g lock(-5)

 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers
1) How to handle lock(-n) where n < -1. e.g lock(-5)
2) How to handle lock(n) such that n does not exist in db.db e.g lock(9999999)
Is it really required to handle such invalid arguments?
In both cases getRecord() method return an non null DataInfo object, so we can never come to know whether recno actually exist and valid. It only throws a IOException when one try to lock an record which is marked for deletion.
Amit
[ July 07, 2002: Message edited by: Amit Kr Kumar ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about if you throw the exception up to the client, and then show a pop up says something like, "Could not Lock Record". That works for botht the incorrect record number or passing -5.
Mark
 
Amit Kr Kumar
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark
But how to handle locks like lock(9999999) becoz getRecord(99999) does not throw any exception. It just return u a DataInfo object with all the values as blank
Amit
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's true, you can write code in there to check to make sure it is a valid number. My lock does not return anything it is void, so I don't understand the DataInfo[] being filled with null.
Also the only thing that calls lock is in the Facade class, that gets the record number from the data they selected in the JTable, so the record has to exist, otherwise it wouldn't be in the JTable, so therefore all calls to lock will have the correct record number, and I don't have to worry about 99999999, or -5 being called to lock().
Hope that helps
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic