Connect() public method

public Connect ( string host, string userId, string userPwd, string dbName ) : void
host string
userId string
userPwd string
dbName string
return void
示例#1
0
        public void Initialize(String host, String userId, String userPwd, String dbName)
        {
            if (_cancelTasks != null)
                throw new AegisException(AegisResult.AlreadyInitialized);


            //  Connection Test
            try
            {
                DBConnector dbc = new DBConnector();
                dbc.Connect(host, userId, userPwd, dbName);
                dbc.Close();
            }
            catch (Exception e)
            {
                throw new AegisException(AegisResult.MySqlConnectionFailed, e, "Invalid MySQL connection.");
            }


            HostAddress = host;
            UserId = userId;
            UserPwd = userPwd;
            DBName = dbName;


            _cancelTasks = new CancellationTokenSource();
        }
示例#2
0
        public void Initialize(String host, String userId, String userPwd, String dbName)
        {
            if (_cancelTasks != null)
            {
                throw new AegisException(AegisResult.AlreadyInitialized);
            }


            //  Connection Test
            try
            {
                DBConnector dbc = new DBConnector();
                dbc.Connect(host, userId, userPwd, dbName);
                dbc.Close();
            }
            catch (Exception e)
            {
                throw new AegisException(AegisResult.MySqlConnectionFailed, e, "Invalid MySQL connection.");
            }


            HostAddress = host;
            UserId      = userId;
            UserPwd     = userPwd;
            DBName      = dbName;


            _cancelTasks = new CancellationTokenSource();
        }
示例#3
0
        public void IncreasePool(Int32 count)
        {
            while (count-- > 0)
            {
                DBConnector dbc = new DBConnector();
                dbc.Connect(HostAddress, UserId, UserPwd, DBName);


                using (_lock.WriterLock)
                {
                    _listPoolDBC.Add(dbc);
                }
            }
        }
示例#4
0
        internal DBConnector GetDBC()
        {
            DBConnector dbc;


            using (_lock.WriterLock)
            {
                if (_listPoolDBC.Count == 0)
                {
                    dbc = new DBConnector();
                    dbc.Connect(HostAddress, UserId, UserPwd, DBName);
                }
                else
                {
                    dbc = _listPoolDBC.ElementAt(0);
                    _listPoolDBC.RemoveAt(0);
                    _listActiveDBC.Add(dbc);
                }
            }

            return(dbc);
        }
示例#5
0
        public void IncreasePool(Int32 count)
        {
            while (count-- > 0)
            {
                DBConnector dbc = new DBConnector();
                dbc.Connect(HostAddress, UserId, UserPwd, DBName);


                using (_lock.WriterLock)
                {
                    _listPoolDBC.Add(dbc);
                }
            }
        }
示例#6
0
        internal DBConnector GetDBC()
        {
            DBConnector dbc;


            using (_lock.WriterLock)
            {
                if (_listPoolDBC.Count == 0)
                {
                    dbc = new DBConnector();
                    dbc.Connect(HostAddress, UserId, UserPwd, DBName);
                }
                else
                {
                    dbc = _listPoolDBC.ElementAt(0);
                    _listPoolDBC.RemoveAt(0);
                    _listActiveDBC.Add(dbc);
                }
            }

            return dbc;
        }