• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

DuplicateKeyException - B&S

 
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!