There are two different types of exceptions in Java. Checked exceptions require that the exception be handled at compile time using a method declaration or a try / catch block. Runtime exceptions do not have this requirement.
You cannot add a new type of exception to the declaration of an overridden method, so you need to either catch the exception, or handle it internally, or use the exception at run time.
It looks like in your case, you probably want to catch the exceptions from the database and handle them well in your code. It is possible that if access to the database fails, you may display an error message explaining the problem.
If you just throw an exception at runtime, then the user is likely to get a forced close screen, which is a pretty bad choice for the UX perspective.
source share