aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RecordNotFoundException in each method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RecordNotFoundException in each method" Watch "RecordNotFoundException in each method" New topic
Author

RecordNotFoundException in each method

Sergey Bylokhov
Greenhorn

Joined: Dec 21, 2009
Posts: 14
Hello Everyone,
I know that this theme was discussed early.

But i still do not understand how to implement this requirement:
My DBMain:


And i have this must option in assignment:
Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.

All my methods has throws RecordNotFoundException; How I can throw RecordNotFoundException from the find method?

I was try to implement it but get strange results:
This code fails with RecordNotFoundException:

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?

Got a deadlock here because thread starting wait and there is no way to unlock it:

Can I lock one record twice from one client? In java doc i see only "Locks a record so that it can only be updated or deleted by this client."
there is no info about locking.


Thanks for help.

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5407
    
  13

Hi Sergey,

How I can throw RecordNotFoundException from the find method?
For example when no record is matching the criteria (instead of returning an empty array or null).

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?
I used the search engine and someone had a similar question. Take a look here.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Sergey Bylokhov
Greenhorn

Joined: Dec 21, 2009
Posts: 14
What about twice locking the same record by the same client. Can i throw IllegalStateException?

Roel De Nijs wrote:Hi Sergey,

How I can throw RecordNotFoundException from the find method?
For example when no record is matching the criteria (instead of returning an empty array or null).

Can I just write in javadoc its not necessary to unlock record after delete because it was unlocked inside delete method?
I used the search engine and someone had a similar question. Take a look here.

Kind regards,
Roel



Yes i know this approach when you extend sun interface and change only signature in this interface. But SUN try to test it in this way


Strange requirement=(
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5407
    
  13

Hi Sergey,

Yes, you can throw an IllegalStateException when a record is trying to lock the same record. In my solution i simply throw an IllegalStateException if a thread/client is trying to lock a record if it has already locked a record (even if he's trying to lock the same record).

I used also my own interface (extending Sun's interface) and added some methods + changed some method declarations (but it were still legal overrides) and I passed the SCJD exam (so did a whole lot of other ranchers), so I don't think it is a problem if you do it too.

Kind regards,
Roel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RecordNotFoundException in each method