/**
   * Gets a question from the database not currently in the HashMap
   *
   * @return - a new question
   */
  private MazeQuestion getNewQuestion() {
    maxQuestionID = getMaxQuestionID();
    Random rng = new Random(System.currentTimeMillis() + System.nanoTime());
    int modValue = uniqueInstance.getMaxQuestionID() + 1;

    MazeQuestion newQuestion = null;

    while (newQuestion == null) {
      int toTry = rng.nextInt(modValue);

      if (questionHashMap.containsKey(new Integer(toTry))) {
        continue;
      }

      try {
        Class.forName("org.sqlite.JDBC");
      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
        System.exit(0);
      }

      try (Connection connection = DriverManager.getConnection(MazeDB.getDBPath()); ) {
        connection.setAutoCommit(false);
        try (Statement statement = connection.createStatement();
            ResultSet rs =
                statement.executeQuery("SELECT * FROM QUESTION WHERE ID = " + toTry + ";"); ) {
          if (rs.next()) {

            int newQuestionID = rs.getInt(1);
            char newQuestionType = rs.getString(2).charAt(0);
            char newFileType = rs.getString(3).charAt(0);
            String newQuestionText = rs.getString(4);
            String newAnswerText = rs.getString(5);
            String newFilePath = rs.getString(6);

            // unescape SQL '
            newQuestionText = newQuestionText.replaceAll("''", "'");

            newQuestion =
                new MazeQuestion(
                    newQuestionID,
                    newQuestionType,
                    newFileType,
                    newQuestionText,
                    newAnswerText,
                    newFilePath);

          } else {
            continue;
          }
        }
      } catch (Exception e) {
        System.err.println(e.getClass().getName() + ": " + e.getMessage());
        System.exit(0);
      }
    }
    return newQuestion;
  }