File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes What condition throw DuplicateKeyException? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "What condition throw DuplicateKeyException?" Watch "What condition throw DuplicateKeyException?" New topic

What condition throw DuplicateKeyException?

Along huang
Ranch Hand

Joined: Feb 09, 2004
Posts: 72
hi,my assignment is URLybird.

Are the key name field and location field? if sure, a hotel only have a room in this database, it seem to deviate the social truth.

I can't decide the design yet, please anyone get me a idea.

best regards!

SCJP1.4 SCJD 2<br />SCEA(In progressing)
HaoZhe Xu
Ranch Hand

Joined: Nov 03, 2003
Posts: 222
I met the same problem when i was doing the project, my understanding may be wrong: it may be thrown when you creating a new record, the instructions told you that you can reuse a deleted one if available, in this case, a DuplicateKeyException will be thrown. if there's no deleted record, you have to create a new one at the back of the file, so this exception will not be thrown.
I think you understand what i am talking about...forgive my poor English

Jan Rotthaus
Ranch Hand

Joined: Jun 23, 2004
Posts: 56

I have the B&S assignment, but the data interface is very similar. I decided, that because there is no key, no DuplicateKeyException can be thrown. But that's just my decision, if something else makes more sense to you, do it that way. Just remember to document your decision in your "choices.txt"!


SCJP 1.4, SCJD, SCBCD 1.3, SCMAD 1.0
OCUP Fundamental
Robert Konigsberg
Ranch Hand

Joined: Jun 23, 2004
Posts: 172
I think there are no conditions to throw DuplicateKeyExceptions.

So I don't throw DuplicateKeyException, and in my documentation I explain that.

SCJP 1.4 (91%)<br />SCJD 1.4 (376/400, 94%)
I agree. Here's the link:
subject: What condition throw DuplicateKeyException?
It's not a secret anymore!