• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DuplicateKeyException - do I have to create a class for this?

 
Leah Knowles
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roel De Nijs
Sheriff
Posts: 10591
140
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Leah Knowles
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you all for your replies, you were so quick

It is clear to me now

Leah
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic