aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: DuplicateRecordException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "B&S: DuplicateRecordException" Watch "B&S: DuplicateRecordException" New topic
Author

B&S: DuplicateRecordException

Laura Pecoraro
Ranch Hand

Joined: Mar 31, 2009
Posts: 45
Hi all

I have a question... so... the method throws a DuplicateKeyException



but, if the primary key is recNo and the create methods returns this number for a new records (my solution appends the record to end of database file), how to possible generate this exception ???

Thanks again, Laura
K. Tsang
Ranch Hand

Joined: Sep 13, 2007
Posts: 1219

In fact the create method shouldn't throw the DuplicateKeyException because the key is the record number. If you don't reuse record number why need to bother. If you do reuse record number, how could you check that name/location etc is the same. Therefore you may ignore this exception. Do document your decision in the choices.txt file.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD
Laura Pecoraro
Ranch Hand

Joined: Mar 31, 2009
Posts: 45
K. Tsang wrote:In fact the create method shouldn't throw the DuplicateKeyException because the key is the record number. If you don't reuse record number why need to bother. If you do reuse record number, how could you check that name/location etc is the same. Therefore you may ignore this exception. Do document your decision in the choices.txt file.


Thanks Tsang

Laura
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: B&S: DuplicateRecordException
 
Similar Threads
JavaDoc DB Interface & DuplicateKeyException
Primary key and update method strange issue
when to throw DuplicateKeyException
Doubt about recNo in URLyBird 1.1.2
No way to throw DuplicateKeyException