public void changeType(Account pAccount, String newType)
      throws SQLException, ConnectionException, NullAccountException, EmailException {
    String demotionSql =
        "DELETE FROM " // cancella vecchie info
            + pAccount.getTypeAccount()
            + "WHERE fkAccount = '"
            + testEmail(pAccount.getSecondaryEmail())
            + "'";

    String toProfessorSql =
        "INSERT INTO professor " // se nuovo professor
            + "(fkAccount,link,department)"
            + "VALUES ('"
            + testEmail(pAccount.getSecondaryEmail())
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "'";

    String toPhdSql =
        "INSERT INTO phdstudent "
            + "(fkAccount,telephone,link,deparment,researchInterest,fkCycle"
            + "fkCurriculum, fkProfessor )" // nuovo dottorando
            + "VALUES ('"
            + testEmail(pAccount.getSecondaryEmail())
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "',"
            + "'"
            + "null"
            + "'";

    String changeTypeSql =
        "UPDATE account" // aggiorna il tipo
            + "set typeAccount = '"
            + newType
            + "' WHERE email = '"
            + pAccount.getEmail();

    Connection connect = null;
    try {
      connect = DBConnection.getConnection();
      pAccount = testAccount(pAccount);

      if (newType.equals("phdstudent") && pAccount.getTypeAccount().equals("basic")) {
        Utility.executeOperation(connect, toPhdSql); // diventa un dottorando
        Utility.executeOperation(connect, changeTypeSql); // cambia tipo in account
      } else if (newType.equals("phdstudent") && pAccount.getTypeAccount().equals("professor")) {
        Utility.executeOperation(connect, demotionSql); // perde info phd
        Utility.executeOperation(connect, toPhdSql); // nuove info prof
        Utility.executeOperation(connect, changeTypeSql);
      } else if (newType.equals("professor") && pAccount.getTypeAccount().equals("basic")) {
        Utility.executeOperation(connect, toProfessorSql);
        Utility.executeOperation(connect, changeTypeSql);
      } else if (newType.equals("professor") && pAccount.getTypeAccount().equals("phdstudent")) {
        Utility.executeOperation(connect, demotionSql);
        Utility.executeOperation(connect, toProfessorSql);
        Utility.executeOperation(connect, changeTypeSql);
      } else if (newType.equals("basic")) {
        Utility.executeOperation(connect, demotionSql);
        Utility.executeOperation(connect, changeTypeSql);
      }

    } finally {
      DBConnection.releaseConnection(connect);
    }
  }