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.
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