This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes No way to throw DuplicateKeyException 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 "No way to throw DuplicateKeyException" Watch "No way to throw DuplicateKeyException" New topic
Author

No way to throw DuplicateKeyException

Jianping Wang
Ranch Hand

Joined: May 29, 2010
Posts: 60

I don't know on what condition will the DuplicateKeyException be thrown. because this method is synchronized and the recNo is allocated inside this method.


SCJP 6 with 93%
Oracle Database SQL Expert with 98%
Martin Krischik
Greenhorn

Joined: Apr 29, 2010
Posts: 23

May I quote the the instruction.html to you (no ridicule, I mean it as an honest hint):

This document deliberately leaves some issues unspecified, and some problems unraised. Your ability to think through these issues, in the face of realistically imperfect specifications, and come to a tenable solution is something upon which you are being graded.


My solution is not the raise DuplicateKeyException at all. I have not yet passed so I might be wrong.

Martin


SCJP, SCJD, OCPJBCD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5133
    
  12

I didn't throw a DuplicateKeyException from create method, because there is simply no appropriate key. In a hotel there can be more than 1 room available for the same night with the same characteristics. So when room numbers will be added to the database file, it makes sense to throw the DuplicateKeyException, but at this moment it doesn't. Of course I documented this decision in choices.txt


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
Consider Paul's rocket mass heater.
 
subject: No way to throw DuplicateKeyException
 
Similar Threads
Threads
Nested synchronized for raf
UrlYBird - DuplicateKeyException in the create method ?
Primary key and update method strange issue
My design choices