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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
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: 2526
    
    8

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 OCPWCD5 OCPBCD5
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://aspose.com/file-tools
 
subject: B&S: DuplicateRecordException