//AsyncQueryRunner.java public <T> Future<T> query(final String sql, final ResultSetHandler<T> rsh) throws SQLException { return executorService.submit(new Callable<T>() { @Override public T call() throws Exception { return queryRunner.query(sql, rsh); } }); }看到executorService.submit与Future<T>了吧#关于异步调用的知识大家可以参见拙作
//BeanHandler.java @Override public T handle(ResultSet rs) throws SQLException { return rs.next() ? this.convert.toBean(rs, this.type) : null; }这个convert就是转换的核心,在BeanHandler初始化的时候就已经有了。
@Override public List<T> handle(ResultSet rs) throws SQLException { List<T> rows = new ArrayList<T>(); while (rs.next()) { rows.add(this.handleRow(rs)); } return rows; } protected abstract T handleRow(ResultSet rs) throws SQLException;
原文地址:http://blog.csdn.net/dlf123321/article/details/45203171