为ex创建一个接口。可执行文件:
public interface Executable() { void exec() throws SqlException(); }将每个dao方法重构为:
public void method1() { execute(new Executable() { @Override public void exec() throws SqlException() { // your pre here } }); }创建以下方法在您的DAO中执行:
private void execute(Executor ex) { try { ex.exec(); } catch(...) { ... } finally { ... }}


