List of usage examples for org.apache.commons.dbutils QueryRunner QueryRunner
public QueryRunner(DataSource ds)
DataSource
to use. From source file:esg.node.filters.AccessLoggingDAO.java
public void setDataSource(DataSource dataSource) { this.dataSource = dataSource; this.queryRunner = new QueryRunner(dataSource); this.idResultSetHandler = new ResultSetHandler<Integer>() { public Integer handle(ResultSet rs) throws SQLException { if (!rs.next()) { return -1; }//w ww . j av a2s. co m return rs.getInt(1); } }; }
From source file:com.pinterest.deployservice.db.DBAgentDAOImpl.java
private long countDeployingAgentInternal(String envId, int firstDeploy) throws Exception { Long n = new QueryRunner(dataSource).query(GET_DEPLOYING_TOTAL, SingleResultSetHandlerFactory.<Long>newObjectHandler(), envId, DeployStage.SERVING_BUILD.toString(), firstDeploy);// w ww .j a v a2 s .c om return n == null ? 0 : n; }
From source file:com.pinterest.deployservice.db.DBHostDAOImpl.java
@Override public void deleteAllById(String id) throws Exception { new QueryRunner(dataSource).update(DELETE_ALL_BY_ID, id); }
From source file:com.pinterest.deployservice.db.DBBuildDAOImpl.java
@Override public List<String> getBranches(String buildName) throws Exception { QueryRunner run = new QueryRunner(this.dataSource); return run.query(GET_BRANCHES, SingleResultSetHandlerFactory.<String>newListObjectHandler(), buildName); }
From source file:com.pinterest.deployservice.db.DBDeployDAOImpl.java
@Override public List<DeployBean> getAcceptedDeploysDelayed(String envId, long before, long after) throws Exception { ResultSetHandler<List<DeployBean>> h = new BeanListHandler<>(DeployBean.class); return new QueryRunner(dataSource) .query(String.format(GET_ACCEPTED_DEPLOYS_DELAYED_TEMPLATE, envId, after, before), h); }
From source file:io.apiman.gateway.engine.jdbc.JdbcMetricsTest.java
/** * Asserts the row count of the given query. * @param count/* ww w.j a v a 2 s. c o m*/ * @param query * @param params * @throws SQLException */ private void assertRowCount(int count, String query, Object... params) throws SQLException { QueryRunner run = new QueryRunner(ds); int actualCount = run.query(query, COUNT_HANDLER, params); Assert.assertEquals(count, actualCount); }
From source file:com.pinterest.deployservice.db.DBEnvironDAOImpl.java
@Override public List<String> getOverrideHosts(String envId, String envName, String envStage) throws Exception { return new QueryRunner(dataSource).query(GET_OVERRIDE_HOSTS_BY_CAPACITY, SingleResultSetHandlerFactory.<String>newListObjectHandler(), envId, envName, envStage); }
From source file:com.pinterest.deployservice.db.DBHostDAOImpl.java
@Override public void removeHostFromGroup(String hostId, String groupName) throws Exception { new QueryRunner(dataSource).update(REMOVE_HOST_FROM_GROUP, hostId, groupName); }
From source file:com.pinterest.deployservice.db.DBAgentDAOImpl.java
@Override public long countSucceededAgent(String envId, String deployId) throws Exception { Long n = new QueryRunner(dataSource).query(GET_SUCCEEDED_TOTAL, SingleResultSetHandlerFactory.<Long>newObjectHandler(), envId, deployId, DeployStage.SERVING_BUILD.toString()); return n == null ? 0 : n; }
From source file:io.apiman.gateway.engine.jdbc.PollCachingJdbcRegistry.java
/** * Checks the ES store to see if the 'dataVersion' entry has been updated with a newer * version #. If it has, then we need to invalidate our cache. *///from w ww.j a va 2 s . c om protected void checkCacheVersion() { // Be very aggressive in invalidating the cache. boolean invalidate = true; QueryRunner run = new QueryRunner(ds); try { long latestVersion = run.query("SELECT version FROM gw_dataversion", Handlers.LONG_HANDLER); //$NON-NLS-1$ if (latestVersion > -1 && dataVersion > -1 && latestVersion == dataVersion) { invalidate = false; } else { dataVersion = latestVersion; } } catch (SQLException e) { // TODO need to use the gateway logger to log this! e.printStackTrace(); } if (invalidate) { invalidateCache(); } }