Ejemplo n.º 1
0
  private void Updategenre2(int id) throws SQLException {
    boolean exit_Add = false;
    Map<Integer, String> m = as.listGenre2();
    String name;
    do {
      System.out.println();
      System.out.println("Enter the new Genre Name:");

      name = sc.nextLine();

      if (!m.containsKey(name)) {
        Genre g = new Genre();
        g.setGenreId(id);
        g.setGenreName(name);
        try {
          as.updateGenre(g);
          System.out.println("Update successful");
          exit_Add = true;
        } catch (Exception e) {
          System.out.println(e.getMessage());
        }

      } else {
        System.out.println("Update successful");
      }

      if (!exit_Add) {
        System.out.println();
        System.out.println();
        System.out.println("Press ' q '  to return or any other key to continue");
        String option = (sc.nextLine());
        if (option.length() > 0) {
          switch (option.charAt(0)) {
            case 'q':
              exit_Add = true;
              break;

            default:
              exit_Add = false;
              break;
          }
        }
      }

    } while (!exit_Add);
  }