File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DuplicateKeyException

 
Mike Tilling
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you help please

in the UrlyBird assignement, the create method throws a DuplicateKeyException, in the database file there is no field for "key",

the database fields are

1-name
2-location
3-Size
4-smoking
5-Rate
6-Date
7-owner

Under which condition the "DuplicateKeyException" should be thrown when creating a new record?

Best Regards
Mike
 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mike,

Does it need to be thrown at all? Just because your interface declares the exception, it doesn't mean you have to throw it.

You can read my thoughts on the subject, but I believe this is an overt attempt by Sun to trip you up a little.

Kevin
[ February 17, 2006: Message edited by: Kevin Conaway ]
 
Mike Tilling
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kevin

In the assignement they said that it must be thrown

Thanks
Mike
 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,

When you say it must be thrown, what do you mean? Do you mean the your interface declares DuplicateKeyException? Or is there a line of text in your spec somewhere saying, "Throw DuplicateKeyException if x..."

Kevin
 
Mike Tilling
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin
Yes, there is a line of text in my spec saying that create method must throw
DuplicateKeyException :

public int create(String [] data) throws DuplicateKeyException;

Many thanks
 
Kevin Conaway
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike,

That is just an interface declaration. Like I said, just because the method declares the Exception, it does not mean you have to throw it.

The following is perfectly legal Java code:



Kevin
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic