Obtain the connection factory
{@inheritDoc}
434159
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
      throws Exception
   {
      Reference ref = (Reference)obj;
      String className = (String)ref.get("class").getContent();
      String cfname = (String)ref.get("name").getContent();

      return objs.get(qualifiedName(cfname, className));
   }
55618
public function getConnection($name = null)
    {
        $this->serviceContext = static::CONNECTION_CONTEXT;
        $result = parent::getConnection($name);
        $this->serviceContext = null;
        return $result;
    }
855864
public function getConnection()
    {
        $repositoryConfig = $this->repositoryConfigurationProvider->getRepositoryConfig();
        // Taking provided connection name if any.
        // Otherwise, just fallback to the default connection.

        if (isset($repositoryConfig['search']['connection'])) {
            $doctrineConnectionId = sprintf('doctrine.dbal.%s_connection', $repositoryConfig['search']['connection']);
        } else {
            // "database_connection" is an alias to the default connection, set up by DoctrineBundle.
            $doctrineConnectionId = 'database_connection';
        }

        if (!$this->container->has($doctrineConnectionId)) {
            throw new InvalidArgumentException(
                "Invalid Doctrine connection '{$repositoryConfig['search']['connection']}' for repository '{$repositoryConfig['alias']}'." .
                'Valid connections are ' . implode(', ', array_keys($this->container->getParameter('doctrine.connections')))
            );
        }

        return $this->container->get($doctrineConnectionId);
    }
478325
protected function getConnectionInstance($datasource)
    {
        $buildConnection = $this->getConnection($datasource);

        $dsn = str_replace("@DB@", $datasource, $buildConnection['dsn']);

        // Set user + password to null if they are empty strings or missing
        $username = isset($buildConnection['user']) && $buildConnection['user'] ? $buildConnection['user'] : null;
        $password = isset($buildConnection['password']) && $buildConnection['password'] ? $buildConnection['password'] : null;

        $con = ConnectionFactory::create(['dsn' => $dsn, 'user' => $username, 'password' => $password], AdapterFactory::create($buildConnection['adapter']));

        return $con;
    }
351428
public function getConnection()
    {
        if (null === $this->conn) {
            $this->checkConfiguration();

            try {
                $this->conn = new SQL(
                    $this->buildDsn(),
                    $this->config['username'],
                    $this->config['password']
                );
            } catch (Exception $e) {
                throw new RuntimeException(static::E_CONNECT);
            }
        }

        return $this->conn;
    }
352610
public function connection()
    {
        if (!is_object($this->db)) {
            $this->db = new \MysqliDb();
            $this->db->addConnection($this->dbName, $this->database);
        }

        return $this;
    }
870188
function getConnection() {
        try {
            if (is_null($this->conn)) {
                $this->conn = new PDO($this->getDbDsn(), $this->getDbUser(), $this->getDbPass());
            }
            return $this->conn;
        } catch (PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
            die();
        }
    }
476830
protected function getConnection()
    {
        $hosts = $this->getHostList();

        while ($host = array_shift($hosts)) {
            try {
                return $this->connectSocket($host);
            } catch (ConnectionException $connectionException) {
                if (empty($hosts)) {
                    throw new ConnectionException("Could not connect to a broker", [], $connectionException);
                }
            }
        }
    }
588885
protected function getConnection()
    {
        $generatorConfig = $this->getGeneratorConfig();
        $database = $generatorConfig->getConfigProperty('reverse.connection');

        if (null === $database) {
            throw new BuildException('No configured connection. Please add a connection to your configuration file
            or pass a `connection` option to your command line.');
        }

        return $generatorConfig->getConnection($database);
    }
1352636
public function getConnection(string $connectionName)
  {
    $connection = $this->findConnection($connectionName);

    if (is_null($connection)) {
      $connection = $this->createConnection($connectionName);

      if (!is_null($connection)) {
        $this->addConnection($connection);
      }
    }

    return $connection;
  }
364007
public function getConnection()
    {
        if ($this->connection instanceof ConnectionInterface === FALSE)
        {
            $this->connection = Propel::getConnection();
        }

        return $this->connection;
    }
203655
protected function getConnection()
    {
        $connection = $this->getClient()->getConnection();

        if ($connection instanceof ReplicationInterface) {
            $connection->switchTo('master');
        }

        return $connection;
    }
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;
    }
694395
protected function getConnection($context)
    {
        $connectionName = null;

        if (!empty($context['options']['db_connection_name'])) {
            $connectionName = $context['options']['db_connection_name'];
        }

        return $this->doctrine->getConnection($connectionName);
    }
304011
public static function getInstanceAndConnect() {
		if (!is_object(self::getInstance())) {
			return NULL;
		}
		if (!self::$instance->tryConnect()) {
			return NULL;
		}
		return self::$instance;
	}
79415
public function getConnection($context = null)
    {
        $db = $this->getDb($context);
        return $this->_di->getShared($db);
    }
282352
public function getConnection($connectionName = null)
    {
        /** @var Configuration $configuration */
        $configuration = $this->get('configuration');
        $connectionName = null !== $connectionName ?: $configuration['connection_name'];
        
        return $this->getConnectionManager()->getConnection($connectionName);
    }