public String loginLogout(MainFrame frame) {
    String res = ""; // 結果を入れる変数
    if (flagLogin) {
      flagLogin = false;
      frame.buttonLog.setLabel(" ログイン");
    } else {

      LoginDialog ld = new LoginDialog(frame);
      ld.setVisible(true);
      ld.setModalityType(LoginDialog.ModalityType.APPLICATION_MODAL);

      if (ld.canceled) {
        return "";
      }

      reservation_userid = ld.tfUserID.getText();

      String password = ld.tfPassword.getText();
      // (2) MySQLの操作(SELECT文の実行)
      try { // userの情報を取得するクエリ
        MySQL mysql = new MySQL();
        ResultSet rs = mysql.getLogin(reservation_userid);
        if (rs.next()) {
          rs.getString("password");
          String password_from_db = rs.getString("password");
          if (password_from_db.equals(password)) { // 認証成功
            flagLogin = true;
            frame.buttonLog.setLabel("ログアウト");
            res = "";
          } else {
            // 認証失敗
            res = "ログインできません.ID パスワードが違います";
          }
        } else { // 認証失敗;
          res = "ログインできません.ID パスワードが違います。";
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return res;
  }