protected void commitOrRollback(String cmdName) {
    if (!error && commit(conn)) {
      long executionTime = System.currentTimeMillis() - startTime;
      String execTimeStr = SQLExecutionHelper.millisecondsToSeconds(executionTime);
      String infoMsg =
          cmdName
              + " "
              + NbBundle.getMessage(
                  SQLStatementExecutor.class, "MSG_execution_success", execTimeStr);
      dataView.setInfoStatusText(infoMsg);
      executeOnSucess(); // delegate
    } else {
      rollback(conn);
      reinstateToolbar();

      String msg = cmdName + " " + NbBundle.getMessage(SQLStatementExecutor.class, "MSG_failed");
      if (ex == null) {
        errorMsg = msg + " " + errorMsg;
      } else {
        errorMsg = msg;
      }

      ex = new DBException(errorMsg, ex);
      dataView.setErrorStatusText(ex);

      NotifyDescriptor nd =
          new NotifyDescriptor.Message(ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
      DialogDisplayer.getDefault().notify(nd);
    }
  }
  public void run() {
    assert task != null;
    try {
      startTime = System.currentTimeMillis();
      ProgressHandle handle = ProgressHandleFactory.createHandle(title, this);
      handle.setDisplayName(titleMsg);
      handle.start();
      try {
        handle.switchToIndeterminate();
        dataView.setInfoStatusText(""); // NOI18N
        errorMsg = ""; // NOI18N
        dataView.disableButtons();

        conn = DBConnectionFactory.getInstance().getConnection(dataView.getDatabaseConnection());
        String msg = "";
        if (conn == null) {
          Throwable connEx = DBConnectionFactory.getInstance().getLastException();
          if (connEx != null) {
            msg = connEx.getMessage();
          } else {
            msg =
                NbBundle.getMessage(
                    SQLStatementExecutor.class,
                    "MSG_connection_failure",
                    dataView.getDatabaseConnection());
          }
          NotifyDescriptor nd = new NotifyDescriptor.Message(msg);
          DialogDisplayer.getDefault().notify(nd);
          return;
        }
        lastCommitState = setAutocommit(conn, false);
        execute(); // delegate
      } finally {
        handle.finish();
      }
    } catch (Exception e) {
      this.ex = e;
    } finally {
      if (ex != null) {
        errorMsg += ex.getMessage();
        error = true;
      }
      finished(); // delegate
      resetAutocommitState(conn, lastCommitState);
    }
  }