-1

I wanted to check the a particular entry is already in database table. For instance, when the user is registered, I wanted to check whether the username and dob is already there in the table. If it is there I wanted to show it in client that it is already there. In this scenario, do I need to create custom exception? if custom exception is required should it be checked or unchecked exception? I am quite confused in which scenario I would use checked and unchecked exception? And if the custom exception has to be written,dont I need to pass the username and dob as parameters to the custom exception? Otherwise if just the exception has to throw we can use either throw new exception("username"+usernmae+" and "+dob+" already exists") or

throw new RuntimeException("username"+usernmae+" and "+dob+" already exists"). 
user414967
  • 5,225
  • 10
  • 40
  • 61

1 Answers1

0

I think the Exception will be unchecked , from what i understand from your question you will input username and dob from the user and check whether the fields exist in your database or not, you can do these things at Runtime only, in other words, only at Runtime you would be able to know if you got an exception or not so it would be a Runtime Exception(UnChecked Exception)

Sarthak Mittal
  • 5,794
  • 2
  • 24
  • 44