• Post Reply Bookmark Topic Watch Topic
  • New Topic

DuplicateKeyException - B&S  RSS feed

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!