-
Notifications
You must be signed in to change notification settings - Fork 0
JDBC Exception Handling
The JDBC API is designed such that almost every method throws the checked
SQLException
type. As observed by others, this isn't very useful, since
in many circumstances it isn't feasible to recover from an SQLException
.
All components of Fluent JDBC are designed to wrap SQLException
in an
unchecked SQLRuntimeException
.
Interface methods that your code implements are designed to throw SQLException
so that you don't have to worry about catching it and rethrowing it. For
example, in our demo RowMapper
we invoked several methods of the
java.sql.ResultSet
interface each of which throws SQLException
. When
Fluent JDBC invokes our row mapper, it will take care of catching and
rethrowing any SQLException
that occurs.
No effort is made to translate SQL exceptions into more meaningful exception types, since the intended use of this library is for utility tasks such as data migration. If this is a feature of significant interest, it could be implemented -- feel free to submit a pull request!