Пример #1
0
  public Notice getNoticeByName(String name) {
    Notice notice = new Notice();

    try {
      Connection con = dbConnection.CONN();

      PreparedStatement stmt = con.prepareStatement("SELECT * FROM Notices WHERE Name = ?");
      stmt.setString(1, name);
      ResultSet rs = stmt.executeQuery();
      rs.next();
      notice.setName(rs.getString("Name"));
      notice.setDescription(rs.getString("Description"));
      notice.setAddress(rs.getString("Address"));
      notice.setTime(rs.getString("Time"));

      rs.close();
      stmt.close();
      con.close();
    } catch (Exception e) {
      Log.e("ERROR", e.getMessage());
    }

    return notice;
  }