コード例 #1
0
        public void Open()
        {
            if (Connection != null)
            {
                return;
            }

            if (!string.IsNullOrWhiteSpace(ConnectionString))
            {
                Helper.ParseConnectionString(ConnectionString, Options);
            }

            Connection = MyRawConnectionPool.Next(Options.Key);
            if (Connection != null)
            {
                // Reuse a pooled connection
                Pooled = true;
                Connection.Reset();
            }
            else
            {
                // Create a new connection
                Pooled     = false;
                Connection = new Connection();
                HandleOkPacket(Connection.Setup(Options));
            }

            UpdateDatabaseName();
            if (Database != Options.Database)
            {
                ChangeDatabase(Options.Database);
            }
        }
コード例 #2
0
        public void Close()
        {
            if (Connection != null)
            {
                MyRawConnectionPool.Consume(Options.Key, Connection, null);
            }

            Connection = null;
        }