@Override public List<JSONObject> getRandomly(final int fetchSize) throws RepositoryException { final List<JSONObject> jsonObjects = new ArrayList<>(); final StringBuilder sql = new StringBuilder(); JSONArray jsonArray; final Connection connection = getConnection(); getRandomly(fetchSize, sql); try { jsonArray = JdbcUtil.queryJsonArray(sql.toString(), new ArrayList<>(), connection, getName(), debug); for (int i = 0; i < jsonArray.length(); i++) { jsonObjects.add(jsonArray.getJSONObject(i)); } } catch (final Exception e) { LOGGER.log(Level.ERROR, "Get randomly failed", e); throw new RepositoryException(e); } return jsonObjects; }
@Override public List<JSONObject> select(final String statement, final Object... params) throws RepositoryException { JSONArray jsonResults; final Connection connection = getConnection(); try { if (null == params || 0 == params.length) { jsonResults = JdbcUtil.queryJsonArray(statement, Collections.emptyList(), connection, getName(), debug); } else { jsonResults = JdbcUtil.queryJsonArray(statement, Arrays.asList(params), connection, getName(), debug); } return CollectionUtils.jsonArrayToList(jsonResults); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Select failed", e); throw new RepositoryException(e); } }
final JSONArray jsonResults = JdbcUtil.queryJsonArray(sql.toString(), paramList, connection, getName(), query.isDebug());
@Override public List<JSONObject> getRandomly(final int fetchSize) throws RepositoryException { final List<JSONObject> jsonObjects = new ArrayList<>(); final StringBuilder sql = new StringBuilder(); JSONArray jsonArray; final Connection connection = getConnection(); getRandomly(fetchSize, sql); try { jsonArray = JdbcUtil.queryJsonArray(sql.toString(), new ArrayList<>(), connection, getName(), debug); for (int i = 0; i < jsonArray.length(); i++) { jsonObjects.add(jsonArray.getJSONObject(i)); } } catch (final Exception e) { LOGGER.log(Level.ERROR, "Get randomly failed", e); throw new RepositoryException(e); } return jsonObjects; }
@Override public List<JSONObject> select(final String statement, final Object... params) throws RepositoryException { JSONArray jsonResults; final Connection connection = getConnection(); try { if (null == params || 0 == params.length) { jsonResults = JdbcUtil.queryJsonArray(statement, Collections.emptyList(), connection, getName(), debug); } else { jsonResults = JdbcUtil.queryJsonArray(statement, Arrays.asList(params), connection, getName(), debug); } return CollectionUtils.jsonArrayToList(jsonResults); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Select failed", e); throw new RepositoryException(e); } }
final JSONArray jsonResults = JdbcUtil.queryJsonArray(sql.toString(), paramList, connection, getName(), query.isDebug());