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:cn.itcast.bbs.dao.TopicDao.java

public void updateTopic(Topic topic) throws SQLException {
    QueryRunner runner = new QueryRunner(JdbcUtil.getDataSource());
    String sql = "update topic set title=?,content=? where id=?;";
    runner.update(sql, new Object[] { topic.getTitle(), topic.getContent(), topic.getId() });
}

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

@Override
public void insert(DataBean bean) throws Exception {
    SetClause setClause = bean.genSetClause();
    String clause = String.format(INSERT_DATA_TEMPLATE, setClause.getClause());
    new QueryRunner(dataSource).update(clause, setClause.getValueArray());
}

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

@Override
public List<ConfigHistoryBean> getByConfigId(String configId, int pageIndex, int pageSize) throws Exception {
    QueryRunner run = new QueryRunner(this.dataSource);
    long start = (pageIndex - 1) * pageSize;
    ResultSetHandler<List<ConfigHistoryBean>> h = new BeanListHandler<ConfigHistoryBean>(
            ConfigHistoryBean.class);
    return run.query(GET_ALL_BY_CONFIG_ID, h, configId, start, pageSize);
}

From source file:azkaban.database.AbstractJdbcLoader.java

protected QueryRunner createQueryRunner() {
    return new QueryRunner(dataSource);
}

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

@Override
public void delete(String envId) throws Exception {
    new QueryRunner(dataSource).update(DELETE, envId);
}

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

@Override
public void insert(UserRolesBean bean) throws Exception {
    SetClause setClause = bean.genSetClause();
    String clause = String.format(INSERT_TEMPLATE, setClause.getClause());
    new QueryRunner(dataSource).update(clause, setClause.getValueArray());
}

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

@Override
public SpotAutoScalingBean getClusterByAutoScalingGroup(String autoScalingGroup) throws Exception {
    ResultSetHandler<SpotAutoScalingBean> h = new BeanHandler<>(SpotAutoScalingBean.class);
    return new QueryRunner(dataSource).query(GET_CLUSTER_BY_ID, h, autoScalingGroup);
}

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

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

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

@Override
public AsgAlarmBean getAlarmInfoById(String alarmId) throws Exception {
    ResultSetHandler<AsgAlarmBean> h = new BeanHandler<AsgAlarmBean>(AsgAlarmBean.class);
    return new QueryRunner(dataSource).query(GET_ALARM_BY_ID, h, alarmId);
}

From source file:com.pinterest.clusterservice.db.DBClusterDAOImpl.java

@Override
public void update(String clusterName, ClusterBean bean) throws Exception {
    SetClause setClause = bean.genSetClause();
    String clause = String.format(UPDATE_CLUSTER_CONFIG, setClause.getClause());
    setClause.addValue(clusterName);//w w  w . j a  v  a2  s . c  o  m
    new QueryRunner(dataSource).update(clause, setClause.getValueArray());
}