Esempio n. 1
0
 public override void Open()
 {
     if (this.State == ConnectionState.Open)
     {
         throw new InvalidOperationException(Resources.ConnectionAlreadyOpen);
     }
     this.SetState(ConnectionState.Connecting, true);
     if (this.settings.AutoEnlist && (Transaction.Current != null))
     {
         this.driver = DriverTransactionManager.GetDriverInTransaction(Transaction.Current);
         if ((this.driver != null) && (this.driver.IsInActiveUse || !this.driver.Settings.EquivalentTo(this.Settings)))
         {
             throw new NotSupportedException(Resources.MultipleConnectionsInTransactionNotSupported);
         }
     }
     try {
         if (this.settings.Pooling)
         {
             MySqlPool pool = MySqlPoolManager.GetPool(this.settings);
             if (this.driver == null)
             {
                 this.driver = pool.GetConnection();
             }
             this.procedureCache = pool.ProcedureCache;
         }
         else
         {
             if (this.driver == null)
             {
                 this.driver = Driver.Create(this.settings);
             }
             this.procedureCache = new GodLesZ.Library.MySql.Data.MySqlClient.ProcedureCache((int)this.settings.ProcedureCacheSize);
         }
     } catch (Exception) {
         this.SetState(ConnectionState.Closed, true);
         throw;
     }
     this.SetState(ConnectionState.Open, false);
     this.driver.Configure(this);
     if ((this.settings.Database != null) && (this.settings.Database != string.Empty))
     {
         this.ChangeDatabase(this.settings.Database);
     }
     if (this.driver.Version.isAtLeast(5, 0, 0))
     {
         this.schemaProvider = new ISSchemaProvider(this);
     }
     else
     {
         this.schemaProvider = new SchemaProvider(this);
     }
     this.perfMonitor = new PerformanceMonitor(this);
     if ((Transaction.Current != null) && this.settings.AutoEnlist)
     {
         this.EnlistTransaction(Transaction.Current);
     }
     this.hasBeenOpen = true;
     this.SetState(ConnectionState.Open, true);
 }
Esempio n. 2
0
        public static void RemoveConnection(Driver driver)
        {
            MySqlPool pool = driver.Pool;

            if (pool != null)
            {
                pool.RemoveConnection(driver);
            }
        }
Esempio n. 3
0
 private static void ClearPoolByText(string key)
 {
     lock (pools.SyncRoot) {
         MySqlPool item = pools[key] as MySqlPool;
         clearingPools.Add(item);
         item.Clear();
         pools.Remove(key);
     }
 }
Esempio n. 4
0
		public static MySqlPool GetPool(MySqlConnectionStringBuilder settings) {
			string connectionString = settings.GetConnectionString(true);
			lock (pools.SyncRoot) {
				MySqlPool pool = pools[connectionString] as MySqlPool;
				if (pool == null) {
					pool = new MySqlPool(settings);
					pools.Add(connectionString, pool);
				} else {
					pool.Settings = settings;
				}
				return pool;
			}
		}
Esempio n. 5
0
        public static MySqlPool GetPool(MySqlConnectionStringBuilder settings)
        {
            string connectionString = settings.GetConnectionString(true);

            lock (pools.SyncRoot) {
                MySqlPool pool = pools[connectionString] as MySqlPool;
                if (pool == null)
                {
                    pool = new MySqlPool(settings);
                    pools.Add(connectionString, pool);
                }
                else
                {
                    pool.Settings = settings;
                }
                return(pool);
            }
        }
Esempio n. 6
0
 public static void RemoveClearedPool(MySqlPool pool)
 {
     clearingPools.Remove(pool);
 }
Esempio n. 7
0
		public static void RemoveClearedPool(MySqlPool pool) {
			clearingPools.Remove(pool);
		}