コード例 #1
0
        /// <summary>
        /// Loads the properties from the connected server into a hashtable
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        private Hashtable LoadServerProperties(MySqlConnection connection)
        {
            // load server properties
            Hashtable    hash = new Hashtable();
            MySqlCommand cmd  = new MySqlCommand("SHOW VARIABLES", connection);

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                try
                {
                    while (reader.Read())
                    {
                        string key   = reader.GetString(0);
                        string value = reader.GetString(1);
                        hash[key] = value;
                    }
                }
                catch (Exception ex)
                {
                    MySqlTrace.LogError(ThreadID, ex.Message);
                    throw;
                }
            }

            if (hash.Contains("max_allowed_packet"))
            {
                maxPacketSize = Convert.ToInt64(hash["max_allowed_packet"]);
            }
            return(hash);
        }
コード例 #2
0
        private Driver TryToGetDriver()
        {
            int count = Interlocked.Decrement(ref available);

            if (count < 0)
            {
                Interlocked.Increment(ref available);
                return(null);
            }
            try
            {
                Driver driver = GetPooledConnection();
                return(driver);
            }
            catch (Exception ex)
            {
                MySqlTrace.LogError(-1, ex.Message);
                Interlocked.Increment(ref available);
                throw;
            }
        }
コード例 #3
0
        public PerformanceMonitor(MySqlConnection connection)
        {
            this.connection = connection;

            string categoryName = Resources.PerfMonCategoryName;

            if (connection.Settings.UsePerformanceMonitor && procedureHardQueries == null)
            {
                try
                {
                    procedureHardQueries = new PerformanceCounter(categoryName,
                                                                  "HardProcedureQueries", false);
                    procedureSoftQueries = new PerformanceCounter(categoryName,
                                                                  "SoftProcedureQueries", false);
                }
                catch (Exception ex)
                {
                    MySqlTrace.LogError(connection.ServerThread, ex.Message);
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Loads all the current character set names and ids for this server
        /// into the charSets hashtable
        /// </summary>
        private void LoadCharacterSets(MySqlConnection connection)
        {
            MySqlCommand cmd = new MySqlCommand("SHOW COLLATION", connection);

            // now we load all the currently active collations
            try
            {
                using (MySqlDataReader reader = cmd.ExecuteReader())
                {
                    charSets = new Hashtable();
                    while (reader.Read())
                    {
                        charSets[Convert.ToInt32(reader["id"], NumberFormatInfo.InvariantInfo)] =
                            reader.GetString(reader.GetOrdinal("charset"));
                    }
                }
            }
            catch (Exception ex)
            {
                MySqlTrace.LogError(ThreadID, ex.Message);
                throw;
            }
        }