/** * Get ratings and feedbacks * * @return list of ratings and feedbacks in Rating objects * @throws SQLException */ public ArrayList<Rating> getRatingsAndFeedbacks() throws SQLException { String sql = "SELECT * FROM Rating"; try { Statement statement = (Statement) connection.createStatement(); ResultSet rs = statement.executeQuery(sql); ArrayList<Rating> list = new ArrayList<>(); while (rs.next()) { Rating rating = new Rating(); rating.setCID(rs.getInt("cID")); rating.setFeedback(rs.getString("feedback")); rating.setStars(rs.getInt("stars")); list.add(rating); } if (statement != null) { statement.close(); } return list; } catch (SQLException e) { e.printStackTrace(); System.out.println("Error! Cannot get ratings and feedbacks"); return null; } }