private static ArrayList<Media> result2Media(ResultSet results)
      throws SQLException {
    int mId, duration, numRating;
    double price, avgRating;
    String creator, name, genre, type;
    ArrayList<Media> mediaObjs = new ArrayList<Media>();
    // can handle null input
    if (results == null) {
      return null;
    }
    while (results.next()) {
      mId = results.getInt("mId");
      creator = results.getString("creator");
      name = results.getString("name");
      duration = results.getInt("duration");
      genre = results.getString("genre");
      price = results.getDouble("price");
      numRating = results.getInt("numRating");
      avgRating = results.getDouble("avgRating");
      type = results.getString("type");
      if (type.equalsIgnoreCase("book")) {
        mediaObjs.add(new Audiobook(creator, name, duration, genre, price,
            numRating, avgRating, mId));
      } else if (type.equalsIgnoreCase("album")) {
        mediaObjs.add(new Album(creator, name, duration, genre, price,
            numRating, avgRating, mId));
      } else if (type.equalsIgnoreCase("movie")) {
        mediaObjs.add(new Movie(creator, name, duration, genre, price,
            numRating, avgRating, mId));
      } else {
        mediaObjs.add(new Media(creator, name, duration, genre, price,
            numRating, avgRating, mId));
      }
    }
    return mediaObjs;
  }