Retrieves a connection from the pool.

If the pool has fewer than $pool_size connections in
it, a new connection will be created.

@return ConnectionWrapper a connection
485682
public function get() {
        $num_conns = count($this->queue);
        if ($num_conns < $this->pool_size) {
            try {
                $this->make_conn();
            } catch (NoServerAvailable $e) {
                if ($num_conns == 0)
                    throw $e;
            }
        }
        return array_shift($this->queue);
    }
419801
public function getConnection()
    {
        if ($this->connection === null) {
            $this->connection = new PDO(
                'mysql:dbname=' . $this->database . ';host=' . $this->host,
                $this->username,
                $this->password,
                array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
        }

        return $this->connection;
    }
998579
public function getConnection() {
        if (null === $this->connection) {
            $this->connection = $this->connect();
        }
        return $this->connection;
    }
947773
@Override
	public ThriftConnection<T> getConnection() throws ThriftConnectionPoolException {
		long statsObtainTime = preConnection();

		ThriftConnectionHandle<T> result = (ThriftConnectionHandle<T>) getConnectionInternal();
		if (result != null) {
			postConnection(result, statsObtainTime);
		}

		return result;
	}
1038527
private function getConnectionByQueue(): ConnectionInterface
    {
        if ($this->queue == null) {
            $this->queue = new \SplQueue();
        }
        if (!$this->queue->isEmpty()) {
            return $this->getEffectiveConnection($this->queue->count(), false);
        }

        if ($this->currentCount >= $this->poolConfig->getMaxActive()) {
            if ($this->poolConfig->getMaxWait() > 0 && $this->poolConfig->getWaitStack()->count() > $this->poolConfig->getMaxWait()) {
                throw new Exception('Connection pool queue is full');
            }
            $this->poolConfig->getWaitStack()->push(CoroHelper::getId());
            if (\Swoole\Coroutine::suspend($this->poolConfig->getName()) == false) {
                $this->poolConfig->getWaitStack()->pop();
                throw new Exception('Reach max connections! Can not pending fetch!');
            }
            return $this->getEffectiveConnection($this->queue->count(), false);
        }

        $connect = $this->createConnection();
        $this->currentCount++;

        return $connect;
    }
525363
private static function connection()
    {
        if (!self::$connection) {
            self::$connection = new Connection();
            if (self::$client_id) {
                self::$connection->authenticateOauth(self::$client_id, self::$auth_token);
            } else {
                self::$connection->authenticateBasic(self::$username, self::$api_key);
            }
        }

        return self::$connection;
    }
467722
function getConnector() {
    if (empty($this->connector)) $this->connector = new Connector($this->config);

    return $this->connector;
  }
239919
public function getConnection()
    {
        if(!$this->_connection) {
            $this->_connection = new \Guzzle\Http\Client($this->getHost());
        }

        return $this->_connection;
    }
1037856
private function getConnection() {
        if ($this->connection === null) {
            $this->connection = DriverManager::getConnection($this->params, new Configuration());
        }

        return $this->connection;
    }
430257
public Connection getConnection() throws SQLException {
		
		FinalWrapper<BoneCP> wrapper = this.pool;

        if (wrapper == null) {
                synchronized (this) {
                        if (this.pool == null) {
                        	try{
                        		if (this.getDriverClass() != null){
                        			loadClass(this.getDriverClass());
                        		}
    					
                        		logger.debug(this.toString());
                        		this.pool = new FinalWrapper<BoneCP>(new BoneCP(this));
    				    
                        	} catch (ClassNotFoundException e) {
                        		throw new SQLException(PoolUtil.stringifyException(e));
                        	}
                        }

                        wrapper = this.pool;
                } 
        }

        return wrapper.value.getConnection();
     }
1135695
public function chosen() : ?Connection
    {
        if ($this->helperSet->has($this->helperName)) {
            $connectionHelper = $this->helperSet->get($this->helperName);

            if ($connectionHelper instanceof ConnectionHelper) {
                return $connectionHelper->getConnection();
            }
        }

        return null;
    }
119393
public function getConnection()
    {
        if ($this->_connection) {
            return $this->_connection;
        }

        $this->_connect();

        /**
         * Before MySQL 5.1.17, server-side prepared statements
         * do not use the query cache.
         * @see http://dev.mysql.com/doc/refman/5.1/en/query-cache-operation.html
         *
         * MySQL also does not support preparing certain DDL and SHOW
         * statements.
         * @see http://framework.zend.com/issues/browse/ZF-1398
         */
        $this->_connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);

        return $this->_connection;
    }
996451
public static Connection getconnnection() {
		Connection con = null;
		try {
			con = DriverManager.getConnection(url, userName, password);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return con;
	}
276607
public function getConnection()
    {
        $conn = mysqli_init();
        if ($this->encryption === true) {
            Logger::debug("Getting connection with encryption.");
            mysqli_ssl_set($conn, $this->sslKey, $this->sslCert, $this->sslCA, $this->sslCAPath, null);
            if ($this->port === null) {
                mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName);
            } else {
                mysqli_real_connect(
                    $conn,
                    $this->serverName,
                    $this->username,
                    $this->password,
                    $this->databaseName,
                    $this->port
                );
            }
        } elseif ($this->port === null) {
            mysqli_real_connect($conn, $this->serverName, $this->username, $this->password, $this->databaseName);
        } else {
            mysqli_real_connect(
                $conn,
                $this->serverName,
                $this->username,
                $this->password,
                $this->databaseName,
                $this->port
            );
        }
        return $conn;
    }
1033160
public function getConnection()
    {
        if (empty($this->connection)) {

            if (empty($this->connectionConfig) || !is_array($this->connectionConfig))
                throw new DatabaseException("Connection config is empty or not an array.");

            $connCount = count($this->connectionConfig);
            for($i = 0; $i < $connCount; ++$i)
            {
                $connectionInfo = $this->connectionConfig[$i];

                if (empty($connectionInfo['port']))
                    $connectionInfo['port'] = 3306;

                $dsn = "mysql:dbname={$connectionInfo['database']};host={$connectionInfo['host']};port={$connectionInfo['port']}";
                if (!empty($connectionInfo['unix_socket']))
                    $dsn .= ';unix_socket='.$connectionInfo['unix_socket'];

                try {

                    $trx_attempt = 0;
                    while ($trx_attempt < $this->deadlockRetries) {

                        try {

                            $this->connection = new PDO($dsn, $connectionInfo['username'], $connectionInfo['password'], array(
                                PDO::ATTR_PERSISTENT => (!empty($connectionInfo['persistent'])?StringUtils::strToBool($connectionInfo['persistent']):false),
                                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                                PDO::ATTR_CASE => PDO::CASE_NATURAL,
                                PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
                                PDO::MYSQL_ATTR_DIRECT_QUERY => true,
                                PDO::ATTR_TIMEOUT => (!empty($connectionInfo['timeout'])?$connectionInfo['timeout']:30) ));


                            $this->connDebugString = $connectionInfo['host'].':'.$connectionInfo['database'];
                            $this->currentDBName = $connectionInfo['database'];

                            $this->Logger->debug(array(
                                'SQL'                    => 'CONNECTION - DB: '.$this->connDebugString,
                            ));

                            return $this->connection;

                        } catch (PDOException $pe) {
                            if ((strpos($pe->getMessage(), 'Too many connections') !== FALSE) && ++$trx_attempt < $this->deadlockRetries)
                            {
                                usleep( pow(2,$trx_attempt) * 100000 );
                                continue;
                            }

                            throw $pe;
                        }
                    }

                } catch(PDOException $pe)
                {

                    // if the last connection fails
                    if($i == ($connCount-1))
                        throw new SQLConnectionException($pe->getMessage());
                }
            }
        }

        return $this->connection;
    }
221743
protected function getHandler()
    {
        switch ($this->getConnectionStatus()) {
            case static::CONNECTION_STATUS_NONE:
                $this->launch();
                // no break
            case static::CONNECTION_STATUS_GOOD:
                return $this->handler;
            case static::CONNECTION_STATUS_BAD:
                throw new ConnectionException(
                    "Connection problem. Read your server's log about this, I have no more informations."
                );
            case static::CONNECTION_STATUS_CLOSED:
                throw new ConnectionException(
                    "Connection has been closed, no further queries can be sent."
                );
        }
    }
979750
public function getConnection()
    {
        if ($this->_oConn === null) {
            $this->_oConn = $this->openDatabase(null);
        }

        return $this->_oConn;
    }