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 Additional runtime exceptions in DB interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Additional runtime exceptions in DB interface" Watch "Additional runtime exceptions in DB interface" New topic

Additional runtime exceptions in DB interface

Leszek Zajac

Joined: May 18, 2006
Posts: 19

Maybe I'm paranoid, but:

My DB interface has these methods:

and these cannot be changed. I would like to throw IllegalArgumentException for find() and update() if criteria or data length is not equal to number of fields in file.
But can I do that in my implementation class? update() and unlock() explictly define SecurityException, which is a runtime exception, so throwing additional runtime exceptions seems to be violation of specification. Am I right or wrong?

Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
RuntimeExceptions don't need to be declared in the throws clause of a method, nor do they need to be mentioned in the Javadoc.

IOW, you can throw them from an implementing class without changing the interface definition.

You will possibly also find that you will need to throw additional checked exceptions (somewhat dependent upon your design decisions) which will require a different solution, as you can indeed not change this particular interface (but the assignment says nothing about implementing it DIRECTLY, which should give you a hint as to a possible solution for that).

I agree. Here's the link:
subject: Additional runtime exceptions in DB interface
It's not a secret anymore!