This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DuplicateKeyException - do I have to create a class for this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DuplicateKeyException - do I have to create a class for this?" Watch "DuplicateKeyException - do I have to create a class for this?" New topic
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: 2258
    
    3

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: 221

Hi Leah,

I suppose my confusion is because java does support an exception named DuplicateKeyException


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: 5123
    
  12

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DuplicateKeyException - do I have to create a class for this?
 
Similar Threads
B&S: Unimplemented exceptions
Exceptions created as member classes of package
B&S Data exceptions
RuntimeException or Exception
B&S 2.2.2 - Network Layer Query