In an earlier section, we discussed handling of exceptions in short. Let's find out about it in more detail. The JDBC code forces handling of exceptions through checked exceptions. However, they are generalized, and handled only through DataTrucationException
, SQLException
, BatchUpdateException
, and SQLWarning
. As opposed to JDBC, Spring supports various unchecked exceptions for different scenarios, providing specialized information. The following table shows a few of which we may need frequently:
Spring Exceptions | When are they thrown? |
| This is the root of the Spring Exception hierarchy; we can use it for all situations |
| This is used when you try to access data without the correct authorization to access it |
| This is on no row returned from the database but, at least, one is expected |
| This is when the result size does not match with the expected result size |
|