aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DuplicateKeyException - B&S Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DuplicateKeyException - B&S" Watch "DuplicateKeyException - B&S" New topic
Author

DuplicateKeyException - B&S

Dan Murphy
Ranch Hand

Joined: Mar 29, 2005
Posts: 126
Hi,

The signature of the createRecord() method in the DBAccess interface
(provided with the assignment) is shown below:

/**
* Creates a new record in the database (possibly reusing a deleted entry).
* Inserts the given data, and returns the record number of the new record.
*/
public long createRecord(String [] data) throws DuplicateKeyException;

The schema of this database doesn't have a field suitable for use as a primary key, so the record number should be used to uniquely identify each record. But as the user doesn't specify the position at which to insert the record, I don't see how a DuplicateKeyException could ever be thrown - assuming the program is not faulty and doesn't try to insert records where one already exists.

Cheers.
Dan


SCJP, SCJD, SCWCD
Paul Bourdeaux
Ranch Hand

Joined: May 24, 2004
Posts: 783
The schema of this database doesn't have a field suitable for use as a primary key
Do you have the URLyBird or the B&S assignment. There is a suitable PK for the B&S assignment (name, location), and Sun has confirmed that we can use it. From what I hear, there is no suitable PK for the URLy assignment.

Anyway, do a search on DuplicateKeyException in this forum, and you will find pleanty of opinions. Some choose not to implement it and cite the reasons in the choices.txt. Others, have identified something as a PK and used that.


“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DuplicateKeyException - B&S