List of usage examples for org.apache.commons.dbutils QueryRunner QueryRunner
public QueryRunner(DataSource ds)
DataSource
to use. From source file:com.pinterest.arcee.db.DBImageDAOImpl.java
@Override public List<String> getAppNames() throws Exception { return new QueryRunner(dataSource).query(GET_ALL_APPNAME, SingleResultSetHandlerFactory.<String>newListObjectHandler()); }
From source file:com.pinterest.deployservice.db.DBTagDAOImpl.java
@Override public List<TagBean> getByTargetIdAndType(String target_id, TagTargetType target_type) throws Exception { ResultSetHandler<List<TagBean>> h = new BeanListHandler<TagBean>(TagBean.class); return new QueryRunner(basicDataSource).query(GET_TAG_BY_TARGET_ID_AND_TYPE_TEMPLATE, h, target_id, target_type.toString());//from w ww .ja va 2s. c o m }
From source file:com.example.data.PetData.java
public List<Map<String, Object>> findPetByTags(String tags) throws SQLException { QueryRunner run = new QueryRunner(H2DB.getDataSource()); List<String> tagList = Arrays.asList(tags.split(",")); if (tagList.isEmpty()) return Collections.EMPTY_LIST; else {/*from w w w . j a va2 s .c om*/ return run .query("select * from pet", H2DB.mkResultSetHandler("id", "name", "categoryId", "photoUrls", "tags", "status")) .stream().map(m -> { m.put("photoUrls", H2DB.strToList((String) m.get("photoUrls"))); m.put("tags", H2DB.strToList((String) m.get("tags"))); m.put("category", getCategory(run, (Long) m.get("categoryId"))); m.remove("categoryId"); return m; }).filter(m -> { if (m.get("tags") == null) return false; else { List<String> its = (List<String>) m.get("tags"); List<String> tmp = new ArrayList<>(its); tmp.removeAll(tagList); return tmp.size() != its.size(); } }).collect(Collectors.toList()); } }
From source file:com.pinterest.arcee.db.DBAlarmDAOImpl.java
@Override public void insertAlarmInfo(AsgAlarmBean asgAlarmBean) throws Exception { asgAlarmBean.setLast_update(System.currentTimeMillis()); SetClause setClause = asgAlarmBean.genSetClause(); String clause = String.format(INSERT_ALARM, setClause.getClause()); new QueryRunner(dataSource).update(clause, setClause.getValueArray()); }
From source file:com.pinterest.arcee.db.DBHealthCheckDAOImpl.java
@Override public void updateHealthCheckById(String id, HealthCheckBean healthCheckBean) throws Exception { SetClause setClause = healthCheckBean.genSetClause(); String clause = String.format(UPDATE_HRALTH_CHECK_BY_ID, setClause.getClause()); setClause.addValue(id);/*from www . j a va 2s . c om*/ new QueryRunner(dataSource).update(clause, setClause.getValueArray()); }
From source file:com.pinterest.deployservice.db.DBUserRolesDAOImpl.java
@Override public UserRolesBean getByNameAndResource(String userName, String resourceId, Resource.Type resourceType) throws Exception { ResultSetHandler<UserRolesBean> h = new BeanHandler<>(UserRolesBean.class); return new QueryRunner(dataSource).query(GET_BY_NAME_AND_RESOURCE, h, userName, resourceId, resourceType.toString());// w w w.j av a2 s .c o m }
From source file:com.pinterest.arcee.db.DBGroupMappingDAOImpl.java
@Override public Collection<GroupMappingBean> getGroupMappingsByCluster(String clusterName) throws Exception { ResultSetHandler<List<GroupMappingBean>> h = new BeanListHandler<>(GroupMappingBean.class); return new QueryRunner(dataSource).query(GET_GROUP_MAPPING_BY_CLUSTER, h, clusterName); }
From source file:com.pinterest.deployservice.db.DBHotfixDAOImpl.java
@Override public List<HotfixBean> getHotfixes(String envName, int pageIndex, int pageSize) throws Exception { ResultSetHandler<List<HotfixBean>> h = new BeanListHandler<>(HotfixBean.class); QueryRunner run = new QueryRunner(this.dataSource); return run.query(GET_HOTFIXES, h, envName, (pageIndex - 1) * pageSize, pageSize); }
From source file:com.pinterest.deployservice.db.DBTokenRolesDAOImpl.java
@Override public TokenRolesBean getByToken(String token) throws Exception { ResultSetHandler<TokenRolesBean> h = new BeanHandler<>(TokenRolesBean.class); return new QueryRunner(dataSource).query(GET_BY_TOKEN, h, token); }
From source file:com.pinterest.arcee.db.DBNewInstanceReportDAOImpl.java
@Override public List<String> getNewInstanceIdsByEnv(String envId) throws Exception { return new QueryRunner(dataSource).query(GET_IDS_BY_ENV, SingleResultSetHandlerFactory.<String>newListObjectHandler(), envId); }