Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Exceptions in URLyBird

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I'm just going through the specs for the URLyBird assignment and have a question that I hope those who have passed will be able to shed some light on.

If the create method throws DuplicateKeyException, does this mean that the entire record must be unique in the database, ie. the primary key is a composite of all the fields? If the database itself hands out the id's to inserted records (ensuring they are unique), how is it that such an exception will be thrown? And furthermore, why does the method return an integer id if you are inserting a record with an id already? All this leads me to conclude that there can never be records that have the exact same field values in the database, a situation which seems illogical if there are 2 separate rooms at the same exact hotel on the same exact day.

Why does the find method throw RecordNotFoundException? You aren't searching for a specific record, just matches for criteria, so either there are n results or no results (i.e. not an exception)

My initial thought as far as handling these seemingly nonsensical exceptions thrown from the DBMain interface is to declare the exceptions as descendants of RuntimeException so they don't have to be catered for in my code. Do you think this is something the marker might take exception to (pun intended )?
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, Shubeer!

Champ, these questions have already been answered a million of times, and there have been many good discussions about them. Please, do a search by the terms "DuplicateKeyException" and something like "find method RecordNotFoundException".
 
CLUCK LIKE A CHICKEN! Now look at this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic