File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: DuplicateRecordException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
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
Bartender

Joined: Sep 13, 2007
Posts: 1966
    
    7

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 OCPJP7
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
 
 
subject: B&S: DuplicateRecordException
 
Similar Threads
when to throw DuplicateKeyException
Primary key and update method strange issue
JavaDoc DB Interface & DuplicateKeyException
No way to throw DuplicateKeyException
Doubt about recNo in URLyBird 1.1.2