Beispiel #1
0
  /**
   * Returns the registry entry with the given id
   *
   * @return the read entry
   * @param id the id of the pim registry entry
   * @throws DataAccessException if an error occurs
   */
  public RegistryEntry getEntryById(long id) throws DataAccessException {

    Connection con = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    RegistryEntry entry = null;

    try {

      con = getConnection();
      con.setReadOnly(true);

      ps = con.prepareStatement(queryDesc.getReadEntryQuery());
      ps.setLong(1, id);
      rs = ps.executeQuery();

      while (rs.next()) {
        entry = resultSetToRegistryEntry(rs);
      }

    } catch (Exception e) {
      throw new DataAccessException("Error reading entry with id: " + id, e);
    } finally {
      DBTools.close(con, ps, rs);
    }

    return entry;
  }