@Override public ArrayList<TenantBean> getTenantByExpectedYearofGrad(int year) { try { Connector c = new Connector(); Connection connection = c.getConnection(); String query = "select * from tenant where expectedyearofgrad = ?"; PreparedStatement ps = connection.prepareStatement(query); ps.setInt(1, year); ResultSet resultSet = ps.executeQuery(); ArrayList<TenantBean> list = new ArrayList<TenantBean>(); TenantBean bean = new TenantBean(); int tenantID, expectedyearofgrad; Long contact; String fname, lname, gender, address, degree, school; boolean status; Blob image; while (resultSet.next()) { tenantID = resultSet.getInt("tenantID"); contact = resultSet.getLong("contact"); expectedyearofgrad = resultSet.getInt("expectedyearofgrad"); fname = resultSet.getString("fname"); lname = resultSet.getString("lname"); gender = resultSet.getString("gender"); address = resultSet.getString("address"); degree = resultSet.getString("degree"); school = resultSet.getString("school"); status = resultSet.getBoolean("status"); image = resultSet.getBlob("image"); bean = new TenantBean(); bean.setTenantID(tenantID); bean.setContact(contact); bean.setExpectedyearofgrad(expectedyearofgrad); bean.setFname(fname); bean.setLname(lname); bean.setGender(gender); bean.setDegree(degree); bean.setAddress(address); bean.setSchool(school); bean.setStatus(status); bean.setImage(image); list.add(bean); } return list; } catch (SQLException ex) { Logger.getLogger(TenantDAOImplementation.class.getName()).log(Level.SEVERE, null, ex); } return null; }