java - Does Spring's JdbcTemplate close the connection if an exception is thrown? -
when spring catches sqlexception, close prepared statement, result set, and/or connection before throwing it's own dataaccessexception (runtime) exception?
i have developer wants create aop aspect catch these exceptions , log and/or close connection.
@afterthrowing(pointcut="dataaccessoperation()", throwing="exception") public void dorecoveryactions(joinpoint thisjoinpoint, dataaccessexception exception) { // log and/or close connection }
yes.
that's whole point of jdbctemplate
- handles kinds of boilerplate actions including release of resources. see 12. data access jdbc.
Comments
Post a Comment