@Override public void execute(final String sql) throws DataAccessException { if (logger.isDebugEnabled()) { logger.debug("Executing SQL statement [" + sql + "]"); } class ExecuteStatementCallback implements StatementCallback<Object>, SqlProvider { @Override public Object doInStatement(Statement stmt) throws SQLException { stmt.execute(sql); return null; } @Override public String getSql() { return sql; } } execute(new ExecuteStatementCallback()); }
以上这段代码来自JdbcTemplate
的代码,请问为什么要在execute
方法内定义类ExecuteStatementCallback
呢?这样做有什么好处?
参考new Thread(new Runable())
一周热门 更多>