Ejemplo n.º 1
0
 private void HandleObsolete(string keyword, object value)
 {
     if (String.Compare(keyword, "Use Old Syntax", true) == 0)
     {
         MySqlTrace.LogWarning(-1, "Use Old Syntax is now obsolete.  Please see documentation");
     }
     else if (String.Compare(keyword, "Use Procedure Bodies", true) == 0)
     {
         MySqlTrace.LogWarning(-1, "Use Procedure Bodies is now obsolete.  Use Check Parameters instead");
         CheckParameters = (bool)value;
     }
 }
 internal void Abort()
 {
     try
     {
         driver.Close();
     }
     catch (Exception ex)
     {
         MySqlTrace.LogWarning(ServerThread, String.Concat("Error occurred aborting the connection. Exception was: ", ex.Message));
     }
     finally
     {
         this.isInUse = false;
     }
     SetState(ConnectionState.Closed, true);
 }
        internal void HandleTimeoutOrThreadAbort(Exception ex)
        {
            bool isFatal = false;

            if (isKillQueryConnection)
            {
                // Special connection started to cancel a query.
                // Abort will prevent recursive connection spawning
                Abort();
                if (ex is TimeoutException)
                {
                    throw new MySqlException(Resources.Timeout, true, ex);
                }
                else
                {
                    return;
                }
            }

            try
            {
                // Do a fast cancel.The reason behind small values for connection
                // and command timeout is that we do not want user to wait longer
                // after command has already expired.
                // Microsoft's SqlClient seems to be using 5 seconds timeouts
                // here as well.
                // Read the  error packet with "interrupted" message.
                CancelQuery(5);
                driver.ResetTimeout(5000);
                if (Reader != null)
                {
                    Reader.Close();
                    Reader = null;
                }
            }
            catch (Exception ex2)
            {
                MySqlTrace.LogWarning(ServerThread, "Could not kill query, " +
                                      " aborting connection. Exception was " + ex2.Message);
                Abort();
                isFatal = true;
            }
            if (ex is TimeoutException)
            {
                throw new MySqlException(Resources.Timeout, isFatal, ex);
            }
        }