Exemplo n.º 1
0
  public List<Record> listRecord() {
    Connection con = ConnectionUtils.getConnection();

    List<Record> recordList1 = new ArrayList<Record>();
    try {

      String query = "SELECT bookRecordId,bookId,status,studentId from BookRecord";
      PreparedStatement statement = con.prepareStatement(query);
      ResultSet resultSet = statement.executeQuery();
      while (resultSet.next()) {
        while (resultSet.next()) {
          Record record = new Record();
          record.setBookRecord(resultSet.getString("bookRecordId"));
          record.setBookId(resultSet.getString("bookId"));
          record.setStatus(resultSet.getString("status"));
          record.setStudentId(resultSet.getString("studentId"));

          recordList1.add(record);
        }
      }
    } catch (SQLException ex) {
      throw new IllegalStateException(ex);
    } finally {
      try {
        con.close();
      } catch (SQLException ex2) {
        throw new IllegalStateException(ex2);
      }
    }
    return recordList1;
  }
Exemplo n.º 2
0
  // change the name in the issue Service for createRecord to
  // createSearchBookRecord
  public void createSearchRecord(Record record) {
    // TODO Auto-generated method stub
    List<Record> recordList1 = new ArrayList<Record>();
    Connection con = ConnectionUtils.getConnection();

    String query =
        "SELECT bookRecordId,bookId,status,studentId from BookRecord where bookRecordId =?";
    try {
      PreparedStatement statement = con.prepareStatement(query);
      statement.setString(1, record.getBookRecord());
      ResultSet resultSet = statement.executeQuery();
      while (resultSet.next()) {
        Record record1 = new Record();
        record1.setBookRecord(resultSet.getString("bookRecordId"));
        record1.setBookId(resultSet.getString("bookId"));
        record1.setStatus(resultSet.getString("status"));
        record1.setStudentId(resultSet.getString("studentId"));
        recordList1.add(record1);
      }
    } catch (Exception ex) {
      throw new IllegalStateException(ex);
    } finally {
      try {
        con.close();
      } catch (Exception ex1) {
        throw new IllegalStateException(ex1);
      }
    }
    searchedRecordList = recordList1;
  }
Exemplo n.º 3
0
 public List<Record> getRecord() {
   List<Record> recList = new ArrayList<Record>();
   Connection con = ConnectionUtils.getConnection();
   String qury = "SELECT bookRecordId,bookId,status,studentId from BookRecord";
   try {
     PreparedStatement statement = con.prepareStatement(qury);
     ResultSet resultSet = statement.executeQuery();
     while (resultSet.next()) {
       Record rec = new Record();
       rec.setBookRecord(resultSet.getString("bookRecordId"));
       rec.setBookId(resultSet.getString("bookId"));
       rec.setStatus(resultSet.getString("status"));
       rec.setStudentId(resultSet.getString("studentId"));
       recList.add(rec);
     }
   } catch (Exception ec) {
     throw new IllegalStateException(ec);
   }
   return recList;
 }
Exemplo n.º 4
0
  public void bookRecordList(List<Book> searchedBookList) {
    List<Book> bookList = new ArrayList<Book>();
    bookList = searchedBookList;
    ArrayList<Book> list = (ArrayList<Book>) bookList;
    Iterator<Book> itr = list.iterator();
    while (itr.hasNext()) {
      Book book = itr.next();
      String bookId = book.getbookId();
      Connection con = ConnectionUtils.getConnection();
      try {

        String query =
            "SELECT bookRecordId,bookId,status,studentId from BookRecord where bookId=? and status=?";
        PreparedStatement statement = con.prepareStatement(query);
        statement.setString(1, bookId);
        statement.setString(2, "available");
        ResultSet resultSet = statement.executeQuery();
        while (resultSet.next()) {
          Record record = new Record();
          record.setBookId(resultSet.getString("bookId"));
          record.setBookRecord(resultSet.getString("bookRecordId"));
          record.setStatus(resultSet.getString("status"));
          record.setStudentId(resultSet.getString("studentId"));
          recordList.add(record);
        }
      } catch (Exception ex) {
        throw new IllegalStateException(ex);
      } finally {
        try {
          con.close();
        } catch (Exception ex1) {
          throw new IllegalStateException(ex1);
        }
      }
    }
  }