org.apache.commons.dbutils.handlers.ArrayListHandler Java Examples

The following examples show how to use org.apache.commons.dbutils.handlers.ArrayListHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArrayListHandlerExample.java    From maven-framework-project with MIT License 6 votes vote down vote up
public static void main(String[] args) throws SQLException {

		final String url = "jdbc:h2:./target/test;AUTO_SERVER=TRUE";
		final String driver = "org.h2.Driver";
		final String usr = "sa";
		final String pwd = "";

		QueryRunner run = new QueryRunner();

		DbUtils.loadDriver(driver);
		Connection conn = DriverManager.getConnection(url, usr, pwd);
		// -----------------------------------------------------------------------------------

		try {
			List<Object[]> query = run.query(conn, "SELECT * FROM employee",
					new ArrayListHandler());
			for (Object[] objects : query) {
				System.out.println(Arrays.toString(objects));
			}
		} finally {
			DbUtils.close(conn);
		}

	}
 
Example #2
Source File: DefaultDataAccessor.java    From smart-framework with Apache License 2.0 5 votes vote down vote up
@Override
public List<Object[]> queryArrayList(String sql, Object... params) {
    List<Object[]> arrayList;
    try {
        arrayList = queryRunner.query(sql, new ArrayListHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return arrayList;
}
 
Example #3
Source File: DefaultDataAccessor.java    From smart-framework with Apache License 2.0 5 votes vote down vote up
@Override
public List<Object[]> queryArrayList(String sql, Object... params) {
    List<Object[]> arrayList;
    try {
        arrayList = queryRunner.query(sql, new ArrayListHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return arrayList;
}