myabtis自定义拦截器,如何捕获数据库连接异常,如下代码能否捕获
public Object intercept(Invocation invocation) {
Object target = invocation.getTarget();
SqlCount.increment();
System.out.println("current sql count = " + SqlCount.getValue());
long startTime = System.currentTimeMillis();
StatementHandler statementHandler = (StatementHandler) target;
try {
return invocation.proceed();
}catch (Exception e){
logger.info("-------------------------------------");
System.out.println(e.getClass());
return "fail";
}finally {
long endTime = System.currentTimeMillis();
long timeCount = endTime - startTime;
logger.info("执行 SQL:[ ]执行耗时[ {} ms]", timeCount);
}
}
我在本地测试,关闭数据库后此实现并不能捕获netException
有什么方式可以在拦截器层面进行数据库连接异常的捕获吗