Retrieves a resource representing the Connection object that is being
actively used.

@return
A resource representing the Connection object that is being actively
used.

@throws GuacamoleException
If an error occurs while retrieving the Connection.
541257
@Path("connection")
    public DirectoryObjectResource<Connection, APIConnection> getConnection()
            throws GuacamoleException {

        // Return the underlying connection as a resource
        return connectionDirectoryResourceFactory
                .create(userContext, userContext.getConnectionDirectory())
                .getObjectResource(activeConnection.getConnectionIdentifier());

    }
323196
public static function get()
    {

        $database = DatabaseProvider::getDb();
        $r = new \ReflectionMethod(Database::class, 'getConnection');
        $r->setAccessible(true);

        return $r->invoke($database);
    }
670433
private SibRaManagedConnection getAssociatedManagedConnection()
                    throws SIResourceException {

        try {

            if (_managedConnection == null) {

                final ConnectionManager connectionManager = _connectionFactory
                                .getConnectionManager();
                if (connectionManager instanceof LazyAssociatableConnectionManager) {

                    ((LazyAssociatableConnectionManager) connectionManager)
                                    .associateConnection(this, _connectionFactory
                                                    .getManagedConnectionFactory(),
                                                         _requestInfo);

                } else {

                    // We shouldn't have been dissociated if the connection
                    // manager does not support lazy enlistment
                    final ResourceException exception = new ResourceAdapterInternalException(
                                    NLS.getFormattedMessage(
                                                            "LAZY_ENLIST_NOT_SUPPORTED_CWSIV0154",
                                                            new Object[] { connectionManager }, null));
                    if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                        SibTr.exception(this, TRACE, exception);
                    }
                    throw exception;

                }

            }

        } catch (ResourceException exception) {

            FFDCFilter
                            .processException(
                                              exception,
                                              "com.ibm.ws.sib.ra.impl.SibRaConnection.getAssociatedManagedConnection",
                                              "1:1843:1.41", this);

            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEventEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }
            throw new SIResourceException(NLS.getFormattedMessage(
                                                                  "REASSOCIATION_FAILED_CWSIV0155",
                                                                  new Object[] { exception }, null), exception);

        }

        return _managedConnection;

    }
263097
public function getConnection()
    {
        if (null === $this->_conn && null !== $this->_tableName) {

            $this->_conn = \Doctrine::getConnectionByTableName($this->_tableName);
        }

        return $this->_conn;
    }
853271
public DataConnection getConnection() {
        DataConnection connection;

        for (connection = availableConnections.poll();
             connection != null && !connection.isUsable();
             connection = availableConnections.poll())
        {
            if (!connection.isUsable()) {
                connection.close();
            }
        }

        if (connection == null) {
            connection = new DataConnection(getDataUri());

            try {
                connection.connect();
            }
            catch (Exception e) {
                logger.error("[getConnection] could not connect to database", e);
                return null;
            }
        }

        connection.setLocale(threadLocale.getLocale());

        return connection;
    }
1082343
private Connection getConn() {
        Connection connection = localConnection.get();
        return ifNotNullReturn(connection, connection, this.getSql2o().open());
    }
1320933
public function getConnection()
    {
        if (! $this->connection) {
            list($dns, $username, $password) = $this->connectionString();

            $this->setConnection(new \PDO($dns, $username, $password));
        }

        return $this->connection;
    }
1209257
private function _getConnection()
    {
        if (is_resource($this->_db)) {
            return $this->_db;
        } else {
            $this->_db = @sqlite_open($this->_options['cache_db_complete_path']);
            if (!(is_resource($this->_db))) {
                Zend_Cache::throwException("Impossible to open " . $this->_options['cache_db_complete_path'] . " cache DB file");
            }
            return $this->_db;
        }
    }
968636
public function getConnection()
    {
        if (is_null($this->_connection)) {
            $this->setConnection(
                Agl::app()->getConfig('main/db/host'),
                Agl::app()->getConfig('main/db/name'),
                Agl::app()->getConfig('main/db/user'),
                Agl::app()->getConfig('main/db/password')
            );
        }

        return $this->_connection;
    }
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;
    }
141184
public synchronized Connection getConnection() throws SQLException {
        if ((currentTimeMillis() - lastChecked)
        > VALIDITY_CHECK_INTERVAL) {
            logger.trace("Checking connection validity");
            // check the validity of the connection
            boolean valid = false;
            int t = 0;

            while (!valid && t < REATTEMPTS) {
                try {
                    if (connection == null || connection.isClosed()
                            || !connection.isValid(VALIDITY_TIMEOUT)) {
                        logger.info(
                                "Connection to {} is closed or invalid; attempting to re-establish",
                                url);
                        // remove any cached prepared statements for this connection
                        threadedPsMap.remove();

                        // attempt re-establishment
                        this.connection = DriverManager
                                .getConnection(url, user, pass);
                        logger.info("Re-established connection to {}", url);
                        // do not set valid to true - check this new connection
                    } else {
                        valid = true;
                    }
                } catch (SQLException e) {
                    logger.info("Failed to re-establish connection to " +
                            "{}, try {}/{}; Reason: {}",
                            new Object[] { url, t, REATTEMPTS, e.getMessage() });
                    // set connection to null to prevent the same error from continuously
                    // occurring when checking isClosed() or isValid()
                    this.connection = null;
                }
                t++;
            }
            if (!valid) {
                logger.error(
                        "Failed to re-establish a connection to {} after {} attempts",
                        url, REATTEMPTS);
                throw new SQLException(
                        "Unable to re-establish a valid connection",
                        new DBConnectionFailure(url,
                                "Unable to re-establish a valid connection"));
            }
            this.lastChecked = currentTimeMillis();
        }
        return connection;
    }
1028708
public Connection getConnection() throws IOException {
		Connection conn = null;
		if (this.datasource != null) {
			try {
				conn = this.datasource.getConnection();
			} catch (SQLException e) {
				throw new IOException(e);
			}
		}
		return conn;
	}
239919
public function getConnection()
    {
        if(!$this->_connection) {
            $this->_connection = new \Guzzle\Http\Client($this->getHost());
        }

        return $this->_connection;
    }
98304
private function getResource()
    {
        $resource = $this->resourceListing->getResource($this->context->getPath(), $this->context->getVersion());

        if (!$resource instanceof Resource) {
            throw new StatusCode\InternalServerErrorException('Resource is not available');
        }

        return $resource;
    }
1080332
public function getResult()
    {
        $url = $this->buildUrl($this->url);

        try {
            $response = $this->makeRequest($url);

            return $this->prepareResponseResult($response);
        }
        // The client needs to know only one exception, no
        // matter what exception is thrown by Guzzle
         catch (TransferException $e) {
            throw new ConnectionException($e->getMessage());
        }
    }
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;
    }
217755
private Object getConnection() {
        Object connection ;
        if (type == RedisToolsConstant.SINGLE){
            RedisConnection redisConnection = jedisConnectionFactory.getConnection();
            connection = redisConnection.getNativeConnection();
        }else {
            RedisClusterConnection clusterConnection = jedisConnectionFactory.getClusterConnection();
            connection = clusterConnection.getNativeConnection() ;
        }
        return connection;
    }