@Override public JSONObject get(final String id) throws RepositoryException { JSONObject ret; final StringBuilder sql = new StringBuilder(); final Connection connection = getConnection(); try { get(sql); final ArrayList<Object> paramList = new ArrayList<>(); paramList.add(id); ret = JdbcUtil.queryJsonObject(sql.toString(), paramList, connection, getName(), debug); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Get failed", e); throw new RepositoryException(e); } return ret; }
/** * Count. * * @param sql sql * @param paramList paramList * @return count * @throws RepositoryException RepositoryException */ private long count(final StringBuilder sql, final List<Object> paramList) throws RepositoryException { final Connection connection = getConnection(); JSONObject jsonObject; long count; try { jsonObject = JdbcUtil.queryJsonObject(sql.toString(), paramList, connection, getName(), debug); count = jsonObject.getLong(jsonObject.keys().next()); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Count failed", e); throw new RepositoryException(e); } return count; }
/** * Count. * * @param sql sql * @param paramList paramList * @return count * @throws RepositoryException RepositoryException */ private long count(final StringBuilder sql, final List<Object> paramList) throws RepositoryException { final Connection connection = getConnection(); JSONObject jsonObject; long count; try { jsonObject = JdbcUtil.queryJsonObject(sql.toString(), paramList, connection, getName(), debug); count = jsonObject.getLong(jsonObject.keys().next()); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Count failed", e); throw new RepositoryException(e); } return count; }
@Override public JSONObject get(final String id) throws RepositoryException { JSONObject ret; final StringBuilder sql = new StringBuilder(); final Connection connection = getConnection(); try { get(sql); final ArrayList<Object> paramList = new ArrayList<>(); paramList.add(id); ret = JdbcUtil.queryJsonObject(sql.toString(), paramList, connection, getName(), debug); } catch (final Exception e) { LOGGER.log(Level.ERROR, "Get failed", e); throw new RepositoryException(e); } return ret; }