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

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

Introduction

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

Prototype

public QueryRunner(DataSource ds) 

Source Link

Document

Constructor for QueryRunner that takes a DataSource to use.

Usage

From source file:com.pinterest.deployservice.db.DBGroupDAOImpl.java

@Override
public void addGroupCapacity(String envId, String group) throws Exception {
    new QueryRunner(dataSource).update(INSERT_GROUP, group, envId);
}

From source file:com.pinterest.arcee.db.DBAlarmDAOImpl.java

@Override
public void deleteAlarmInfoByGroup(String groupName) throws Exception {
    new QueryRunner(dataSource).update(DELETE_ALARM_BY_GROUP, groupName);
}

From source file:com.pinterest.deployservice.db.DBHotfixDAOImpl.java

@Override
public HotfixBean getByHotfixId(String hotfix_id) throws Exception {
    ResultSetHandler<HotfixBean> h = new BeanHandler<>(HotfixBean.class);
    return new QueryRunner(dataSource).query(GET_HOTFIX_BY_ID, h, hotfix_id);

}

From source file:com.fluke.database.dataservice.IntraDayDao.java

public void insertBatch(String id, List<IntradayTicker> tickers) {
    QueryRunner runner = new QueryRunner(DatabaseProperty.getDataSource());
    Object params[][] = new Object[tickers.size()][7];
    int count = 0;
    for (IntradayTicker ticker : tickers) {
        params[count] = new Object[7];
        params[count][0] = id;/*w  w  w  .  j a v a  2 s  . c o  m*/
        params[count][1] = ticker.getOpenPrice();
        params[count][2] = ticker.getClosePrice();
        params[count][3] = ticker.getHighPrice();
        params[count][4] = ticker.getLowPrice();
        params[count][5] = ticker.getVolume();
        params[count][6] = ticker.getTime();
        count++;
    }
    try {
        runner.batch(sql, params);
    } catch (SQLException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.pinterest.deployservice.db.DBTokenRolesDAOImpl.java

@Override
public TokenRolesBean getByNameAndResource(String userName, String resourceId, Resource.Type resourceType)
        throws Exception {
    ResultSetHandler<TokenRolesBean> h = new BeanHandler<>(TokenRolesBean.class);
    return new QueryRunner(dataSource).query(GET_BY_NAME_AND_RESOURCE, h, userName, resourceId,
            resourceType.toString());/* w w  w  .j  a v  a 2  s  . c o  m*/
}

From source file:com.pinterest.deployservice.db.DBUserRolesDAOImpl.java

@Override
public List<UserRolesBean> getByResource(String resourceId, Resource.Type resourceType) throws Exception {
    ResultSetHandler<List<UserRolesBean>> h = new BeanListHandler<>(UserRolesBean.class);
    return new QueryRunner(dataSource).query(GET_BY_RESOURCE, h, resourceId, resourceType.toString());
}

From source file:com.pinterest.deployservice.db.DBHostTagDAOImpl.java

@Override
public void insertOrUpdate(HostTagBean hostTagBean) throws Exception {
    SetClause setClause = hostTagBean.genSetClause();
    String clause = String.format(INSERT_HOST_TAG_TEMPLATE, setClause.getClause(), HostTagBean.UPDATE_CLAUSE);
    new QueryRunner(dataSource).update(clause, setClause.getValueArray());
}

From source file:com.pinterest.arcee.db.DBHealthCheckDAOImpl.java

@Override
public HealthCheckBean getHealthCheckById(String id) throws Exception {
    ResultSetHandler<HealthCheckBean> h = new BeanHandler<HealthCheckBean>(HealthCheckBean.class);
    return new QueryRunner(dataSource).query(GET_HEALTH_CHECK_BY_ID, h, id);
}

From source file:com.pinterest.deployservice.db.DBGroupRolesDAOImpl.java

@Override
public List<GroupRolesBean> getByResource(String resourceId, Resource.Type resourceType) throws Exception {
    ResultSetHandler<List<GroupRolesBean>> h = new BeanListHandler<>(GroupRolesBean.class);
    return new QueryRunner(dataSource).query(GET_BY_RESOURCE, h, resourceId, resourceType.toString());
}

From source file:com.pinterest.deployservice.db.DBTagDAOImpl.java

@Override
public TagBean getLatestByTargetId(String targetId) throws Exception {
    return new QueryRunner(basicDataSource).query(GET_LATEST_TAG_BY_TARGET_ID, new BeanHandler<>(TagBean.class),
            targetId);/*from   w w  w  .j  a v  a2 s  .  c o m*/
}