class DBQueries {

    public static <O> java.sql.ResultSet search(final Query<O> query, final String tableName, final Connection connection){
        final String selectSql = String.format("SELECT DISTINCT objectKey FROM cqtbl_%s",tableName);
        PreparedStatement statement = null;
        try{
            statement = createAndBindSelectPreparedStatement(selectSql, "", Collections.<WhereClause>emptyList(), query, connection);
            return statement.executeQuery();
        }catch(Exception e){
            DBUtils.closeQuietly(statement);
            throw new IllegalStateException("Unable to execute search. Query: " + query, e);
        }
        // In case of success we leave the statement and result-set open because the iteration of an Index ResultSet is lazy.

    }

}