MySql.Data.MySqlClient.MySqlPoolManager.GetPool C# (CSharp) Method

GetPool() public static method

public static GetPool ( MySqlConnectionStringBuilder settings ) : MySqlPool
settings MySqlConnectionStringBuilder
return MySqlPool
        public static MySqlPool GetPool(MySqlConnectionStringBuilder settings)
        {
            string text = settings.ConnectionString;

            lock (pools.SyncRoot)
            {
                MySqlPool pool = (pools[text] as MySqlPool);

                if (pool == null)
                {
                    pool = new MySqlPool(settings);
                    pools.Add(text, pool);
                }
                else
                    pool.Settings = settings;

                return pool;
            }
        }

Usage Example

コード例 #1
0
 public void Open()
 {
     if (this.state == (ConnectionState)1)
     {
         throw new InvalidOperationException(Resources.ConnectionAlreadyOpen);
     }
     this.SetState((ConnectionState)2);
     try
     {
         if (this.settings.Pooling)
         {
             MySqlPool pool = MySqlPoolManager.GetPool(this.settings);
             this.driver         = pool.GetConnection();
             this.procedureCache = pool.ProcedureCache;
         }
         else
         {
             this.driver         = Driver.Create(this.settings);
             this.procedureCache = new ProcedureCache(this.settings.ProcedureCacheSize);
         }
     }
     catch (Exception)
     {
         this.SetState(0);
         throw;
     }
     if (this.driver.Settings.UseOldSyntax)
     {
         Logger.LogWarning("You are using old syntax that will be removed in future versions");
     }
     this.SetState((ConnectionState)1);
     this.driver.Configure(this);
     if (this.settings.Database != null && this.settings.Database.Length != 0)
     {
         this.ChangeDatabase(this.settings.Database);
     }
     this.hasBeenOpen = true;
 }
All Usage Examples Of MySql.Data.MySqlClient.MySqlPoolManager::GetPool