| Author |
DuplicateKeyException - do I have to create a class for this?
|
Leah Knowles
Greenhorn
Joined: Sep 25, 2009
Posts: 8
|
|
I am confused about my project specifications and how to handle DuplicateKeyException. It is an exception thrown in the interface Sun supplied, as well as RecordNotFoundException.
Example
public int create(String [] data) throws DuplicateKeyException
The instructions read "Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package.
I know I have to create a class for RecordNotFoundException but not sure if I also have to create a class for DuplicateKeyException as well. I suppose my confusion is because java does support an exception named DuplicateKeyException, but if I dont create a class in my project it wont complile.
Thanks in advance for any advice
|
 |
Roberto Perillo
Bartender
Joined: Dec 28, 2007
Posts: 2212
|
|
Howdy, Leah!
Indeed, EJB does have a DuplicateKeyException. But you must create your DuplicateKeyException under the suncertify.db package. And since this is a "must", if you don't create it, you'll fail.
|
Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
|
 |
Carlos Morillo
Ranch Hand
Joined: Jun 06, 2009
Posts: 220
|
|
Hi Leah,
Leah, I am unable to find DuplicateKeyException in the Java 6 API.
In my view you definitely have to declare and create a class DuplicateKeyException under suncertify.db.
Hope this helps,
Carlos.
|
SCSA, OCA, SCJP 5.0, SCJD http://www.linkedin.com/in/carlosamorillo
|
 |
Roel De Nijs
Bartender
Joined: Jul 19, 2004
Posts: 4351
|
|
Hi Leah,
This one should give it away:
Any unimplemented exceptions in this interface must all be created as member classes of the suncertify.db package
The DuplicateKeyException is not implemented in the JDK, you are referring to a class in the JEE. Because you are only allowed to use the JDK (no other jars or third party libraries), you won't find this class. If this class should refer to another one, your interface should have an import-statement (or whould use the fully qualified class name).
So yes, you have to create that exception and make sure you follow the instructions closely (which constructors do you have to provide, etc.).
Kind regards,
Roel
[edit] And I thought I was fast, but beaten by 2 other ranchers
|
SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
|
 |
Leah Knowles
Greenhorn
Joined: Sep 25, 2009
Posts: 8
|
|
Thank you all for your replies, you were so quick
It is clear to me now
Leah
|
 |
 |
|
|
subject: DuplicateKeyException - do I have to create a class for this?
|
|
|