Ejemplo n.º 1
0
        /// <summary>
        /// 创建连接池.
        /// </summary>
        /// <remarks>
        /// isTrackerPool,isStoragePool不能同时为true或者false
        /// </remarks>
        public static void CreatePool(string storageName, DatabaseStyle dbStyle, int minSize, int maxSize)
        {
            switch (dbStyle)
            {
            case DatabaseStyle.MySql:
            {
                IConnectionPool pool =
                    new ConnectionPool <MySqlConnection>(new MySqlConnectionFactory(), minSize, maxSize);
                ConnectionPoolCached.InsertOrUpdate(storageName, pool);
                break;
            }

            case DatabaseStyle.Oracle:
            {
                IConnectionPool pool =
                    new ConnectionPool <OracleConnection>(new OracleConnectionFactory(), minSize, maxSize);
                ConnectionPoolCached.InsertOrUpdate(storageName, pool);
                break;
            }

            case DatabaseStyle.SqlServer:
            default:
            {
                IConnectionPool pool =
                    new ConnectionPool <SqlConnection>(new SqlServerConnectionFactory(), minSize, maxSize);
                ConnectionPoolCached.InsertOrUpdate(storageName, pool);
                break;
            }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到指定的连接池.
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static IConnectionPool GetPool(string stroageName)
        {
            object obj = ConnectionPoolCached.Get(stroageName);

            if (null == obj)
            {
                Logger.Warn("the pool is null.");
                return(null);

                ;
            }
            return((IConnectionPool)obj);
        }