Package net.didion.jwnl.dictionary.database

Examples of net.didion.jwnl.dictionary.database.Query


  }

  public Query getRandomIndexWordQuery(POS pos) throws JWNLException {
    MinMax minMax = _minMaxIds.get(pos);
    if (minMax == null) {
      Query query = createPOSQuery(pos, COUNT_INDEX_WORDS_SQL);
      try {
        query.execute();
        query.getResults().next();
        minMax = new MinMax(query.getResults().getInt(1), query
            .getResults().getInt(2));
        _minMaxIds.put(pos, minMax);
      } catch (SQLException ex) {
        throw new JWNLException("DICTIONARY_EXCEPTION_023", ex);
      } finally {
        if (query != null) {
          query.close();
        }
      }
    }
    int id = minMax.getMin()
        + _rand.nextInt(minMax.getMax() - minMax.getMin());
View Full Code Here


  public Query getExceptionsQuery(POS pos) throws JWNLException {
    return createPOSQuery(pos, ALL_EXCEPTIONS_SQL);
  }

  protected Query createPOSQuery(POS pos, String sql) throws JWNLException {
    Query query = null;
    try {
      query = _connectionManager.getQuery(sql);
      query.getStatement().setString(1, pos.getKey());
      return query;
    } catch (SQLException ex) {
      if (query != null) {
        query.close();
      }
      throw new JWNLException("DICTIONARY_EXCEPTION_023", ex);
    }
  }
View Full Code Here

    }
  }

  protected Query createPOSStringQuery(POS pos, String str, String sql)
      throws JWNLException {
    Query query = null;
    try {
      query = _connectionManager.getQuery(sql);
      query.getStatement().setString(1, pos.getKey());
      query.getStatement().setString(2, str);
      return query;
    } catch (SQLException ex) {
      if (query != null) {
        query.close();
      }
      throw new JWNLException("DICTIONARY_EXCEPTION_023", ex);
    }
  }
View Full Code Here

    }
  }

  protected Query createPOSOffsetQuery(POS pos, long offset, String sql)
      throws JWNLException {
    Query query = null;
    try {
      query = _connectionManager.getQuery(sql);
      query.getStatement().setString(1, pos.getKey());
      query.getStatement().setLong(2, offset);
      return query;
    } catch (SQLException ex) {
      if (query != null) {
        query.close();
      }
      throw new JWNLException("DICTIONARY_EXCEPTION_023", ex);
    }
  }
View Full Code Here

    }
  }

  protected Query createPOSIdQuery(POS pos, int id, String sql)
      throws JWNLException {
    Query query = null;
    try {
      query = _connectionManager.getQuery(sql);
      query.getStatement().setString(1, pos.getKey());
      query.getStatement().setInt(2, id);
      return query;
    } catch (SQLException ex) {
      if (query != null) {
        query.close();
      }
      throw new JWNLException("DICTIONARY_EXCEPTION_023", ex);
    }
  }
View Full Code Here

TOP

Related Classes of net.didion.jwnl.dictionary.database.Query

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.