Example usage for org.apache.commons.dbutils BasicRowProcessor BasicRowProcessor

List of usage examples for org.apache.commons.dbutils BasicRowProcessor BasicRowProcessor

Introduction

In this page you can find the example usage for org.apache.commons.dbutils BasicRowProcessor BasicRowProcessor.

Prototype

public BasicRowProcessor(BeanProcessor convert) 

Source Link

Document

BasicRowProcessor constructor.

Usage

From source file:test.com.handle.DataSource.java

public static <T> List<T> queryBeanList(Class<T> cls, Map<String, String> map, String sql, Object... params)
        throws SQLException {
    Connection conn = ds.getConnection();

    List<T> result = null;/*from w  w  w  .  jav  a 2  s  . c o  m*/
    try {
        if (MapUtils.isNotEmpty(map)) {
            result = runner.query(conn, sql,
                    new BeanListHandler<T>(cls, new BasicRowProcessor(new BeanProcessor(map))), params);
        } else {
            result = runner.query(conn, sql, new BeanListHandler<T>(cls), params);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    shutdown();
    return result;
}