当前位置: 首页>>代码示例>>Java>>正文


Java ArrayListHandler类代码示例

本文整理汇总了Java中org.apache.commons.dbutils.handlers.ArrayListHandler的典型用法代码示例。如果您正苦于以下问题:Java ArrayListHandler类的具体用法?Java ArrayListHandler怎么用?Java ArrayListHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ArrayListHandler类属于org.apache.commons.dbutils.handlers包,在下文中一共展示了ArrayListHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: activatedModuleIdsForUser

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static String[] activatedModuleIdsForUser(long userId) {
    return DB.withConnection(conn -> {

        String[] modules = new QueryRunner()
                .query(conn,
                        "SELECT module_id FROM " + TABLE_NAME
                                + " WHERE user_id = ?",
                        new ArrayListHandler(), userId).stream()
                .map(array -> {
                    String module = (String) array[0];

                    return module;
                }).toArray(String[]::new);

        return modules;
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:18,代码来源:UserModuleActivationPersistency.java

示例2: userActivationsForModule

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static long[] userActivationsForModule(String moduleId) {
    return DB.withConnection(conn -> {

        Long[] userIds = new QueryRunner()
                .query(conn,
                        "SELECT user_id FROM " + TABLE_NAME
                                + " WHERE module_id = ?",
                        new ArrayListHandler(), moduleId).stream()
                .map(array -> {
                    long id = (long) array[0];

                    return id;
                }).toArray(Long[]::new);

        return ArrayUtils.toPrimitive(userIds);
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:18,代码来源:UserModuleActivationPersistency.java

示例3: runListQuery

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
private void runListQuery(List<QueryReporter> reporterList) throws Exception{
        for(QueryReporter queryReporter : reporterList){
            long start = System.currentTimeMillis();
            List<Object[]> arraylist = queryRunner.query(queryReporter.getQueryStr(),
                    new ArrayListHandler());
//            for(Object[] objs : arraylist){
//                for(Object o : objs){
//                    System.out.print(o + ",");
//                }
//                System.out.println();
//            }
            queryReporter.setResult(arraylist);
            queryReporter.setCost(System.currentTimeMillis()-start);
            LOG.debug("{}",queryReporter);
        }
        LOG.debug("\n");
    }
 
开发者ID:yaohuiwu,项目名称:CAM,代码行数:18,代码来源:CriteriaPerformanceTest.java

示例4: main

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
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);
		}

	}
 
开发者ID:v5developer,项目名称:maven-framework-project,代码行数:25,代码来源:ArrayListHandlerExample.java

示例5: queryArrayList

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
/**
 * 查询对应的数据,返回单条记录
 */
public List<Object[]> queryArrayList(String sql, Object... params) {
    List<Object[]> arrayList;
    try {
        arrayList = queryRunner.query(sql, new ArrayListHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!");
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return arrayList;
}
 
开发者ID:smxc,项目名称:garlicts,代码行数:15,代码来源:JdbcTemplate.java

示例6: queryArrayList

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static List<Object[]> queryArrayList(QueryRunner runner, String sql, Object... params) {
    List<Object[]> result;
    try {
        result = runner.query(sql, new ArrayListHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!", e);
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return result;
}
 
开发者ID:thinkhoon,项目名称:tkhoon,代码行数:12,代码来源:DBUtil.java

示例7: activatedModuleEndpointsWithQuery

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
private static ActiveAssistanceModule[] activatedModuleEndpointsWithQuery(
        String query, Object... params) {
    return DB.withConnection(conn -> {

        ActiveAssistanceModule[] modules = new QueryRunner()
                .query(conn, query, new ArrayListHandler(), params)
                .stream()
                .map(UserModuleActivationPersistency::mapModuleEndpoint)
                .toArray(ActiveAssistanceModule[]::new);

        return modules;
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:14,代码来源:UserModuleActivationPersistency.java

示例8: list

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static ActiveAssistanceModule[] list(String language) {
    return DB.withConnection(conn -> {
        String fields = ActiveAssistanceModulePersistency.allFields
                .replace("name", "COALESCE(l.name, m.name)")
                .replace("logo_url", "COALESCE(l.logo_url, m.logo_url)")
                .replace("description_short", "COALESCE(l.description_short, m.description_short)")
                .replace("description_long", "COALESCE(l.description_long, m.description_long)");

        ActiveAssistanceModule[] modules = new QueryRunner()
                .query(conn, "SELECT " + fields + " FROM " + TABLE_NAME + " m LEFT JOIN " + LOCALIZATION_TABLE_NAME + " AS l ON l.module_id = m.id AND l.language_code = ?", new ArrayListHandler(), language)
                .stream()
                .map(array -> {
                    String id = (String) array[0];
                    String name = (String) array[1];
                    String logoUrl = (String) array[2];
                    String description_short = (String) array[3];
                    String description_long = (String) array[4];

                    String requiredCapsRaw = (String) array[5];
                    Capability[] requiredCapabilities = Json.fromJson(Json.parse(requiredCapsRaw), Capability[].class);


                    String optionalCapsRaw = (String) array[6];
                    Capability[] optionalCapabilities = Json.fromJson(Json.parse(optionalCapsRaw), Capability[].class);

                    String copyright = (String) array[7];

                    String administratorEmail = (String) array[8];

                    String supportEmail = (String) array[9];

                    String restAddress = (String) array[10];

                    return new ActiveAssistanceModule(name, id, logoUrl, description_short, description_long, requiredCapabilities, optionalCapabilities, copyright, administratorEmail, supportEmail, restAddress);
                }).toArray(ActiveAssistanceModule[]::new);


        return modules;
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:41,代码来源:ActiveAssistanceModulePersistency.java

示例9: findDevices

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
private static Device[] findDevices(String where, Object... params) {
    return DB.withConnection(conn -> {
        Device[] devices = new QueryRunner()
                .query(conn,
                        "SELECT " + ALL_FIELDS + " FROM " + TABLE_NAME
                                + " " + where, new ArrayListHandler(),
                        params).stream().map(DevicePersistency::convertResultArrayToDevice).toArray(Device[]::new);

        return devices;
    });
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-server,代码行数:12,代码来源:DevicePersistency.java

示例10: getNumberOfTuplesProcessed

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
private int getNumberOfTuplesProcessed(Connection conn, String tableName)
{
  String sqlQuery = "select * FROM " + tableName;
  ResultSetHandler resultSet = new ArrayListHandler();
  QueryRunner run = new QueryRunner();
  try {
    List<Object[]> ouputTuples = (ArrayList<Object[]>)run.query(conn, sqlQuery, resultSet);
    return ouputTuples.size();
  } catch (SQLException e) {
    e.printStackTrace();
  }
  return 0;
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:14,代码来源:ApplicationTest.java

示例11: test2

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
@Test
public void test2() throws SQLException{//���Խ������ÿһ�м�¼����һ�������У�Ȼ��������ӵ�һ��list���ϵķ�ʽ��������
	QueryRunner runner=new QueryRunner(JdbcUtils.getDataSource());//ͨ������һ�����ݿ����ӳأ�����һ��dbutils�������Ӳ��������ֶ��ͷţ�dbutils��ܻ�������ͷ�
	String sql="select * from users";
	List list=(List) runner.query(sql,new ArrayListHandler());
	System.out.println(list);
}
 
开发者ID:mushroomgithub,项目名称:ServletStudyDemo,代码行数:8,代码来源:Demo2.java

示例12: batchQeury

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
/**
 * 返回list加数组
 * @param sql
 * @param params
 * @return
 */
public static List<Object[]> batchQeury(String sql, Object[] params) {
       QueryRunner qr = null;
       List<Object[]> ret = null;
       try {
           qr = DbHelper.getQueryRunner("data1");
           ret = qr.query(sql, params, new ArrayListHandler());
           return ret;
       } catch (Exception e) {
           log.error("数据库查询出错", e);
           if(ret != null) ret.clear();
           return null;
       }
   }
 
开发者ID:taojiaenx,项目名称:taojiane_push,代码行数:20,代码来源:DbHelper.java

示例13: query

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static void query(Connection conn, String sql) throws SQLException {
	
	System.out.println("Query SQL: " + sql);  
	QueryRunner runner = new QueryRunner();
	ArrayListHandler handler = new ArrayListHandler();
	List<Object[]> results = runner.query(conn, sql, handler);
	dumpResults(results);
}
 
开发者ID:teiid,项目名称:teiid-embedded,代码行数:9,代码来源:JDBCUtils.java

示例14: insert

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
public static void insert(Connection conn, String sql) throws SQLException {
    
    System.out.println("Insert SQL: " + sql);
    QueryRunner runner = new QueryRunner();
    ArrayListHandler handler = new ArrayListHandler();
    List<Object[]> results = runner.insert(conn, sql, handler);
    dumpResults(results);
}
 
开发者ID:teiid,项目名称:teiid-embedded,代码行数:9,代码来源:JDBCUtils.java

示例15: findArrayList

import org.apache.commons.dbutils.handlers.ArrayListHandler; //导入依赖的package包/类
/**
 * //TODO 查询数组list
 * 
 * @param sql
 * @param params
 * @return
 */
public static List<Object[]> findArrayList(String sql, Object... params) {
    List<Object[]> arrayList;
    try {
        arrayList = getQueryRunner().query(sql, new ArrayListHandler(), params);
    } catch (SQLException e) {
        logger.error("queryArrayList.查询数组list出错:" + sql, e);
        throw new QueryException(e);
    }
    logger.debug("sql:" + sql + "\n  params:" + Arrays.toString(params));
    return arrayList;
}
 
开发者ID:mattxia,项目名称:unique-web,代码行数:19,代码来源:DB.java


注:本文中的org.apache.commons.dbutils.handlers.ArrayListHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。