Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

lock and RecordNotFoundException

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When lock /unlock /isLocked methods will throw RecordNotFoundException?

Can anybody will let me know .



Thanks
Pramod
 
Mahesh Kumaraguru
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pramod KARNANI wrote:
When lock /unlock /isLocked methods will throw RecordNotFoundException?

Can anybody will let me know .

Thanks
Pramod


Assuming your method signatures without the throws clause are :-

public long lock(long recNo) //return value is cookie
public void unlock(long recNo, long cookie)
public boolean isLocked(long recNo)

then you could throw RecordNotFoundException when the database does not have a record corresponding to recNo.
 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I created separate class ReservationsManager.java like denny's project to implement lock/unlock/isLock methods .
to throw RecordNotFoundException in lock/unlock/isLock I need to have access of recordNumber HashMap that I have ContractorDataAccess class.
ContractorDataAccess class has HashMap of recordNumber .
public static HashMap<Integer, Long> recordNumbers = new HashMap<Integer, Long>();
where key is record number and value is location in file (database file)

Am I correct ?

Let me know.
 
Mahesh Kumaraguru
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not know Denny's project.

What would you do when recordNumbersHashMap.containsKey(recNo) returns false / recordNumbersHashMap.get(recNo) returns null?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic