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);
    }
  }
 private void rollback(Connection conn) {
   try {
     if (conn != null && !conn.getAutoCommit()) {
       conn.rollback();
     }
   } catch (SQLException e) {
     String msg = NbBundle.getMessage(SQLStatementExecutor.class, "MSG_failure_rollback");
     dataView.setErrorStatusText(msg, e);
   }
 }
 private boolean commit(Connection conn) {
   try {
     if (conn != null && !conn.getAutoCommit()) {
       conn.commit();
     }
   } catch (SQLException sqlEx) {
     String msg = NbBundle.getMessage(SQLStatementExecutor.class, "MSG_failure_to_commit");
     dataView.setErrorStatusText(msg, sqlEx);
     ex = sqlEx;
     return false;
   }
   return true;
 }