@Override
    public UsageHistogramBean getUsage(String organizationId, String apiId, String version,
            HistogramIntervalType interval, DateTime from, DateTime to) {
        UsageHistogramBean rval = new UsageHistogramBean();
        Map<Long, UsageDataPoint> index = MetricsAccessorHelper.generateHistogramSkeleton(rval, from, to, interval, UsageDataPoint.class, Long.class);

        try {
            QueryRunner run = new QueryRunner(ds);
            String gbColumn = groupByColumn(interval);
            String sql = "SELECT " + gbColumn + ", count(*) FROM gw_requests WHERE api_org_id = ? AND api_id = ? AND api_version = ? AND rstart >= ? AND rstart < ? GROUP BY " + gbColumn; //$NON-NLS-1$ //$NON-NLS-2$
            ResultSetHandler<UsageHistogramBean> handler = new UsageHistogramHandler(rval, index);
            run.query(sql, handler, organizationId, apiId, version, from.getMillis(), to.getMillis());
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return rval;
    }
@see io.apiman.manager.api.core.IMetricsAccessor#getUsage(java.lang.String, java.lang.String, java.lang.String, io.apiman.manager.api.beans.metrics.HistogramIntervalType, org.joda.time.DateTime, org.joda.time.DateTime)
manager/api/jdbc/src/main/java/io/apiman/manager/api/jdbc/JdbcMetricsAccessor.java