Connection methods --------------------------------------------------------------------------------------------------------
505996
private HttpURLConnection createConnection() {
        String urlString = getRequestInfo().getRequestUrl().toString();
        if( getRequestInfo().requestMethod == null ) {
            throw new KieServerHttpRequestException("Please specify (and execute?) a HTTP method first.");
        }
        try {
            final HttpURLConnection connection;
            if( this.httpProxyHost != null ) {
                Proxy proxy = new Proxy(HTTP, new InetSocketAddress(this.httpProxyHost, this.httpProxyPort));
                connection = CONNECTION_FACTORY.create(getRequestInfo().getRequestUrl(), proxy);
            } else {
                connection = CONNECTION_FACTORY.create(getRequestInfo().getRequestUrl());
            }
            // support for localhost and https
            if (getRequestInfo().getRequestUrl().getProtocol().equalsIgnoreCase("https") && getRequestInfo().getRequestUrl().getHost().equalsIgnoreCase("localhost")) {
                ((HttpsURLConnection) connection).setHostnameVerifier(new HostnameVerifier(){

                    public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
                        if (hostname.equalsIgnoreCase("localhost")) {
                            return true;
                        }
                        return false;
                    }
                });
            }

            connection.setRequestMethod(getRequestInfo().requestMethod);
            return connection;
        } catch( IOException ioe ) {
            throw new KieServerHttpRequestException("Unable to create (" + getRequestInfo().requestMethod + ") connection to '"
                    + urlString + "'", ioe);
        }
    }
135423
Connection getConnection() throws SQLException {
		if (connection == null) {
			connection = connectionSupplier.getConnection();
			initSavepoints(connection);
		}
		return connection;
	}
529101
public function connect()
    {
        $this->isBound = false;
        $this->connection = $this->driver->connect(
            $this->configuration['hostname'],
            $this->configuration['port'],
            $this->configuration['withSSL'],
            $this->configuration['withTLS']
        );

        foreach ($this->configuration['options'] as $key => $value) {
            $this->connection->setOption($key, $value);
        }
    }
1212728
protected function connect()
    {
        // Already connected
        if ($this->database !== null) {
            return;
        }

        $connection = $this->resolver
            ->connection($this->config('connection'));

        if ($connection->getDriverName() !== 'pgsql') {
            throw new \InvalidArgumentException('Connection should use pgsql driver.');
        }

        $this->database = $connection;
    }
940269
public function connect()
    {
        if ($this->isConnected) {
            return false;
        }

        if (!$this->pdo) {
            $this->beforeConnect && call_user_func($this->beforeConnect, $this);

            $dsn = $this->getDsn();
            $attrs = $this->attrs + array(
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_STRINGIFY_FETCHES => true,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
            );

            try {
                $this->pdo = new PDO($dsn, $this->user, $this->password, $attrs);
            } catch (\PDOException $e) {
                $this->connectFails && call_user_func($this->connectFails, $this, $e);
                throw $e;
            }

            $this->afterConnect && call_user_func($this->afterConnect, $this, $this->pdo);
        }

        $this->isConnected = true;

        return true;
    }
998579
public function getConnection() {
        if (null === $this->connection) {
            $this->connection = $this->connect();
        }
        return $this->connection;
    }
1267546
public function registerViaConnectionMethod()
    {
        foreach ($this->classes as $driver => $class) {
            Connection::resolverFor($driver, function ($connection, $database, $prefix, $config) use ($class) {
                return new $class($connection, $database, $prefix, $config);
            });
        }
    }
516098
protected function initializeConnection()
    {
        if (!$this->entityManager instanceof EntityManager) {
            $this->outputLine('This command only supports database connections provided by the Doctrine ORM Entity Manager.
				However, the current entity manager is an instance of %s.', [get_class($this->entityManager)]);
            $this->quit(1);
        }

        $this->dbalConnection = $this->entityManager->getConnection();
    }
270867
Connection getConnection() throws ClassNotFoundException, SQLException{

    Class.forName(job.get(DBConfiguration.DRIVER_CLASS_PROPERTY));

    if(job.get(DBConfiguration.USERNAME_PROPERTY) == null) {
      return DriverManager.getConnection(job.get(DBConfiguration.URL_PROPERTY));
    } else {
      return DriverManager.getConnection(
          job.get(DBConfiguration.URL_PROPERTY), 
          job.get(DBConfiguration.USERNAME_PROPERTY), 
          job.get(DBConfiguration.PASSWORD_PROPERTY));
    }
  }
226697
private void connect() {
        try {
            URL url = new URL(this.endpoint);
            connection = (HttpURLConnection) url.openConnection();
            connection.setReadTimeout(this.readTimeoutMs);
            connection.setConnectTimeout(this.connectTimeoutMs);
            connection.setRequestMethod(this.method.name());
            if (method == HttpMethod.POST || method == HttpMethod.PUT) {
                connection.setDoOutput(true);
            } else {
                connection.setDoOutput(false);
            }
            connection.setDoInput(true);
            connection.setUseCaches(false);
            for (String headerName : headers.keySet()) {
                String headerValue = headers.get(headerName);
                connection.setRequestProperty(headerName, headerValue);
            }
            connection.connect();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
487949
@Override
  public void connect() {
    if (!canRun.compareAndSet(true, false) || clientBase.isDone()) {
      throw new IllegalStateException("There is already a connection thread running for " + this.clientBase);
    }
    executorService.execute(clientBase);
    logger.info("New connection executed: {}", this.clientBase);
  }
1182545
private function checkConnect(): void
    {
        if (empty($this->connect['type']) ||
            empty($this->connect['host']) ||
            empty($this->connect['name']) ||
            empty($this->connect['user'])
        ) {
            throw new ConfigurationException(
                'Database adapter is not configured.
                Please check `db` configuration section: required type, host, db name and user'
            );
        }
    }
680306
public function initConnection(Connection $connection)
    {
        /** @var $pdo PDO */
        $pdo = $connection->getWrappedConnection();
        $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
        $params = $connection->getParams();
        if (!isset($params['charset'])) {
            throw new RuntimeException("No connection charset specified");
        }
        $pdo->exec('SET NAMES ' . $pdo->quote($params['charset']));
    }
981087
public function connect()
	{
		parent::connect();

		$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
		$this->connection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
	}
1059329
public function connect()
    {
        try {
            $this->instance = DriverManager::getConnection($this->config, new Configuration());
            $this->createSchema();

            return true;
        } catch (DBALException $e) {
            throw new DriverConnectionException($e->getMessage());
        }
    }
353280
public void addConnection (Connection connection) {
		if (connection == null) throw new IllegalArgumentException("connection cannot be null.");

		synchronized (connectionsLock) {
			Connection[] newConnections = new Connection[connections.length + 1];
			newConnections[0] = connection;
			System.arraycopy(connections, 0, newConnections, 1, connections.length);
			connections = newConnections;
		}

		connection.addListener(invokeListener);

		if (TRACE) trace("kryonet", "Added connection to ObjectSpace: " + connection);
	}
45811
public function resolveConnection()
    {
        $connection = self::cyrus()->getDatabase();

        $this->setDatabaseConnection($connection);

        return is_object($this->pdo[$connection]) ? $this->pdo[$connection] : null;
    }