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);
}
}
你拦截StatementHandler 那怎么能行,拦截Executor那才稳妥