I downloaded my SCJD assignment yesterday.I went through the specifications and found that the records which are in in the database do not have a primary key.Also,most of the methods like create,update etc have recNo as the parameter.
My doubt is that can I use recNo as the primary key and include it as a record field.This would be similar to the way its done in Andrew`s SCJD book. Then it would also be possible to throw a DuplicateKeyException which is thrown by create() method.
yes, you can use recNo as primary-key in you application, but you cannot add it as a field into the database. You probably have something like "but because the data must continue to be manipulated.." in your assignment.
I did not throw the DuplicateKeyException anywhere in my application, but I'm sure you can. As long as you explain it in your choices.txt, you'll be fine.
"Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface: "
So I think that I have to follow the interface as it is.
[ January 12, 2008: Message edited by: rohan tiwari ]
You're right you must implement the interface so in your implementation class you have to declare your method throws that exception but in your method, you don't have to throw it.
Alex Belisle Turcot
Joined: Apr 26, 2005
The interface tells you which checked exception you can throw. Any other non-specified checked Exception cannot be thrown.
So the interface really doesnt tell you must throw it, but rather that you cannot throw something else. You are free to implement it or not, but it is still a good idea to mention your choice is your design choices doc.
Regards, Alex [ January 12, 2008: Message edited by: Alex Belisle Turcot ]