File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Doubt about recNo in URLyBird 1.1.2 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 "Doubt about recNo in URLyBird 1.1.2" Watch "Doubt about recNo in URLyBird 1.1.2" New topic
Author

Doubt about recNo in URLyBird 1.1.2

rohan tiwari
Ranch Hand

Joined: Sep 13, 2007
Posts: 82
Hello,

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.


SCJP 5, SCWCD 1.4, SCJD 5
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Rohan,

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.

Herman
rohan tiwari
Ranch Hand

Joined: Sep 13, 2007
Posts: 82
The DB interface provided by Sun has a method create() that throws a DuplicateKeyException.
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Originally posted by rohan tiwari:
The DB interface provided by Sun has a method create() that throws a DuplicateKeyException.


The DB interface provided by Sun has a method create() that can throw DuplicateKeyException.

It is possible that your implementation does not throw it. In that case, mention it in your design choices.

Regards,
Alex
rohan tiwari
Ranch Hand

Joined: Sep 13, 2007
Posts: 82
Alex,

it is given that

"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 ]
Oguz Ozun
Greenhorn

Joined: May 10, 2007
Posts: 19
Originally posted by rohan tiwari:
Alex,

it is given that

"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 ]


Hi,

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
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Hi.

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 ]
Michael Fisherman
Greenhorn

Joined: Oct 11, 2007
Posts: 18
How can you have a duplicate key when you are not specifying a key in the first place ? Or is it you might have duplicate keys afterwards if clients created a record at the same time
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Michael,



Good question: that's why I did not use the DuplicateKeyException at all.

Herman
 
 
subject: Doubt about recNo in URLyBird 1.1.2
 
Similar Threads
Doubt on doubt
(B&S)Doubt about my read() concept
lock record method doubt
Doubt...
Doubt on EJBObject