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


Java ArrayHandler类代码示例

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


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

示例1: loadFromMetaData

import org.apache.commons.dbutils.handlers.ArrayHandler; //导入依赖的package包/类
/**
 * @see #loadFromMetaData(RecordMetaData)
 */
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> ret = new ArrayList<>();

    for (RecordMetaData rmd : recordMetaDatas) {
        if (!(rmd instanceof RecordMetaDataJdbc)) {
            throw new IllegalArgumentException(
                "Invalid metadata; expected RecordMetaDataJdbc instance; got: " + rmd);
        }
        QueryRunner runner = new QueryRunner();
        String request = ((RecordMetaDataJdbc) rmd).getRequest();

        try {
            Object[] item = runner
                .query(this.conn, request, new ArrayHandler(), ((RecordMetaDataJdbc) rmd).getParams().toArray());
            ret.add(new org.datavec.api.records.impl.Record(toWritable(item), rmd));
        } catch (SQLException e) {
            throw new IllegalArgumentException("Could not execute statement \"" + request + "\"", e);
        }
    }
    return ret;
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:26,代码来源:JDBCRecordReader.java

示例2: setUp

import org.apache.commons.dbutils.handlers.ArrayHandler; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);    // init the mocks

    when(dataSource.getConnection()).thenReturn(conn);
    when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
    when(stmt.getParameterMetaData()).thenReturn(meta);
    when(stmt.getResultSet()).thenReturn(results);
    when(stmt.executeQuery()).thenReturn(results);
    when(conn.prepareCall(any(String.class))).thenReturn(call);
    when(call.getParameterMetaData()).thenReturn(meta);
    when(call.getResultSet()).thenReturn(results);
    when(call.getMoreResults()).thenReturn(false);
    when(results.next()).thenReturn(false);

     handler = new ArrayHandler();
     runner = new QueryRunner(dataSource);
}
 
开发者ID:apache,项目名称:commons-dbutils,代码行数:19,代码来源:QueryRunnerTest.java

示例3: queryArray

import org.apache.commons.dbutils.handlers.ArrayHandler; //导入依赖的package包/类
public Object[] queryArray(String sql, Object... params) {
    Object[] array;
    try {
        array = queryRunner.query(sql, new ArrayHandler(), params);
    } catch (SQLException e) {
        logger.error("查询出错!");
        throw new RuntimeException(e);
    }
    printSQL(sql);
    return array;
}
 
开发者ID:smxc,项目名称:garlicts,代码行数:12,代码来源:JdbcTemplate.java

示例4: queryArray

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

示例5: test1

import org.apache.commons.dbutils.handlers.ArrayHandler; //导入依赖的package包/类
@Test
public void test1() throws SQLException{//���Խ������ÿһ�м�¼����һ�������У�ע���������Ƕ��У�ֻ���ص�һ�м�¼
	QueryRunner runner=new QueryRunner(JdbcUtils.getDataSource());//ͨ������һ�����ݿ����ӳأ�����һ��dbutils�������Ӳ��������ֶ��ͷţ�dbutils��ܻ�������ͷ�
	String sql="select * from users where id=?";
	Object res[]=(Object[]) runner.query(sql, 1, new ArrayHandler());
	for(int i=0;i<res.length;i++){
		System.out.println(res[i]);
	}
}
 
开发者ID:mushroomgithub,项目名称:ServletStudyDemo,代码行数:10,代码来源:Demo2.java

示例6: findArray

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

示例7: setUp

import org.apache.commons.dbutils.handlers.ArrayHandler; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);

    when(dataSource.getConnection()).thenReturn(conn);
    when(conn.prepareStatement(any(String.class))).thenReturn(stmt);
    when(stmt.getParameterMetaData()).thenReturn(meta);
    when(stmt.getResultSet()).thenReturn(results);
    when(stmt.executeQuery()).thenReturn(results);
    when(results.next()).thenReturn(false);

     handler = new ArrayHandler();
     runner = new AsyncQueryRunner(Executors.newFixedThreadPool(1), new QueryRunner(dataSource));
}
 
开发者ID:apache,项目名称:commons-dbutils,代码行数:15,代码来源:AsyncQueryRunnerTest.java


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