private static String reformatQuery(String _sql) {
        int length = _sql.length();
        int charAdded = 0;
        StringBuilder sql = new StringBuilder(_sql);

        for (int x = 0; x < length; x++) {
            char c = _sql.charAt(x);

            if (c == ',' && x < length - 1 && _sql.charAt(x + 1) != ' ') {
                sql.replace(x + charAdded, x + 1 + charAdded, ", ");
                charAdded++;
            }
        }

        return sql.toString();
    }
@param entries    entries
@param sortByTime sort by time if true, otherwise sort by count
@param first      first index to sort on. Normally 0
@param last       last index to sort on. Normally length -1
xmppserver/src/main/java/org/jivesoftware/database/ProfiledConnection.java