Meaningless Drivel is fun!*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes lock and RecordNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "lock and RecordNotFoundException" Watch "lock and RecordNotFoundException" New topic
Author

lock and RecordNotFoundException

pramod karnani
Ranch Hand

Joined: May 22, 2007
Posts: 88

When lock /unlock /isLocked methods will throw RecordNotFoundException?

Can anybody will let me know .



Thanks
Pramod
Mahesh Kumaraguru
Ranch Hand

Joined: Jun 01, 2005
Posts: 95
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

Joined: May 22, 2007
Posts: 88

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

Joined: Jun 01, 2005
Posts: 95
I do not know Denny's project.

What would you do when recordNumbersHashMap.containsKey(recNo) returns false / recordNumbersHashMap.get(recNo) returns null?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: lock and RecordNotFoundException
 
Similar Threads
B&S: Lock & Unlock Sun Specification
update/delete/unlock/isLocked and RecNotFoundEx
implementing interface methods within another interface method
B&S cookie value
lock(int recNo) throws RecordNotFoundException