/*
 * Copyright 1998-2010 Linux.org.ru
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package ru.org.linux.site;

import java.sql.*;

public class MemoriesListItem {
  private final int id;
  private final int userid;
  private final Timestamp timestamp;
  private final int topic;

  public MemoriesListItem(Connection db, int id) throws SQLException, RecordNotFoundException {
    Statement st = db.createStatement();

    ResultSet rs = st.executeQuery("SELECT * FROM memories WHERE id="+id);

    if (!rs.next()) {
      throw new RecordNotFoundException();
    }

    this.id = id;
    userid = rs.getInt("userid");
    timestamp = rs.getTimestamp("add_date");
    topic = rs.getInt("topic");
  }

  private MemoriesListItem(ResultSet rs) throws SQLException {
    id = rs.getInt("id");
    userid = rs.getInt("userid");
    timestamp = rs.getTimestamp("add_date");
    topic = rs.getInt("topic");
  }

  public static MemoriesListItem getMemoriesListItem(Connection db, int id) throws SQLException {
    Statement st = db.createStatement();

    ResultSet rs = st.executeQuery("SELECT * FROM memories WHERE id="+id);

    if (!rs.next()) {
      return null;
    } else {
      return new MemoriesListItem(rs);
    }
  }

  public int getId() {
    return id;
  }

  public int getUserid() {
    return userid;
  }

  public Timestamp getTimestamp() {
    return timestamp;
  }

  public int getTopic() {
    return topic;
  }

  @Deprecated
  public static int getId(Connection db, int userid, int topic) throws SQLException {
    Statement st = db.createStatement();

    ResultSet rs = st.executeQuery("SELECT id FROM memories WHERE userid="+userid+" AND topic="+topic);

    if (!rs.next()) {
      return 0;
    } else {
      return rs.getInt("id");
    }
  }
}

@@ -820,428 +820,8 @@
 c;%0A%0A
-  public MemoriesListItem(Connection db, int id) throws SQLException, RecordNotFoundException %7B%0A    Statement st = db.createStatement();%0A%0A    ResultSet rs = st.executeQuery(%22SELECT * FROM memories WHERE id=%22+id);%0A%0A    if (!rs.next()) %7B%0A      throw new RecordNotFoundException();%0A    %7D%0A%0A    this.id = id;%0A    userid = rs.getInt(%22userid%22);%0A    timestamp = rs.getTimestamp(%22add_date%22);%0A    topic = rs.getInt(%22topic%22);%0A  %7D%0A%0A
   pr

remove unused constructor