| Author |
B&S: Database file
|
Mickey Mulligan
Greenhorn
Joined: Feb 26, 2006
Posts: 20
|
|
Hi there, the schema for my database file looks like this: subcontractor name, location, specialties, size, rate, owner My question is, do folks generally use the subcontractor name as a primary key? I've chosen not to do this (you might have subcontractors with the same name in different locations), and I use the record's position in the file (ie. its number) as the primary key. Problem is, my interface demands this method: Seeing as I don't pass the primary key into the String [] data array above, (my record is assigned a key by its location in the file) how can I check for a DuplicateKeyException? It's pretty much impossible to get duplicate keys the way I'm doing things. Perhaps I should interpret this as "Duplicate Record"? If so, what's the best way to check for dupes? I would assume it's to keep an array of the hashes of each record and check against that, rather than digging through the database file. Any suggestions?
|
 |
Kristof Janssens
Greenhorn
Joined: Jan 05, 2005
Posts: 23
|
|
|
I don't use that exception. I mentioned in my choices.txt file that this exception cannot be thrown because I also use the record position as primary key. I placed the exception in my methods so it is available for future enhancements, but it is never thrown.
|
SCJP 1.4 (90%)<br />SCJD (in progress)
|
 |
Mickey Mulligan
Greenhorn
Joined: Feb 26, 2006
Posts: 20
|
|
|
Cool, methinks I will do the same, thanks!
|
 |
Ed Tse
Ranch Hand
Joined: Sep 18, 2003
Posts: 183
|
|
|
I saw the same problem but have ignored it since I am working on other areas. from my impression, you can't change the interface that was provided by the assignment, I don't think you can remove the throw from the interface.
|
SCJP, Pre-SCJD (URLyBird 1.3.1), Teradata Cert'd Prof
|
 |
B Chen
Ranch Hand
Joined: Dec 27, 2005
Posts: 89
|
|
|
You cannot remove the exception specification from createRecord in the interface provided by Sun. But you can remove it from createRecord in your implementation class.
|
SCJD<br />SCJP 1.4
|
 |
 |
|
|
subject: B&S: Database file
|
|
|