{@inheritdoc}

@throws BrokenConnectionException
548407
public function getJavaClass(string $class_name): Interfaces\JavaClass
    {
        try {
            $class = $this->pjbProxyClient->getJavaClass($class_name);
        } catch (Pjb62BrokenConnectionException | Exception\InvalidUsageException $e) {
            PjbProxyClient::unregisterInstance();
            throw new BrokenConnectionException($e->getMessage(), $e->getCode(), $e);
        }

        return $class;
    }
56530
public function connect()
    {
        if (!$this->connection) {
            $errNum = $errStr = null;
            $this->connection = @fsockopen($this->host, $this->port, $errNum, $errStr, $this->options['timeout']);

            if (!$this->connection or $errNum > 0) {
                $message = sprintf(
                    'Could not connect to beanstalkd "%s:%d": %s (%d)',
                    $this->host,
                    $this->port,
                    $errStr,
                    $errNum
                );
                throw new Exception\SocketException($message);
            }

            // remove timeout on the stream, allows blocking reserve
            stream_set_timeout($this->connection, -1, 0);
        }

        return $this;
    }
378655
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()) {
            throw new ConnectionException('Connection pool queue is full');
        }

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

        return $connect;
    }
608067
public function checkConnectionError($line) {
		$line = rtrim($line, ')');
		if (substr($line, -23) === ErrorCodes::LogonFailure) {
			throw new AuthenticationException('Invalid login');
		}
		if (substr($line, -26) === ErrorCodes::BadHostName) {
			throw new InvalidHostException('Invalid hostname');
		}
		if (substr($line, -22) === ErrorCodes::Unsuccessful) {
			throw new InvalidHostException('Connection unsuccessful');
		}
		if (substr($line, -28) === ErrorCodes::ConnectionRefused) {
			throw new InvalidHostException('Connection refused');
		}
		if (substr($line, -26) === ErrorCodes::NoLogonServers) {
			throw new NoLoginServerException('No login server');
		}
		if (substr($line, -23) === ErrorCodes::AccessDenied) {
			throw new AccessDeniedException('Access denied');
		}
	}
639534
void deliverError(final OtpCookedConnection conn, final Exception e) {
        removeConnection(conn);
        remoteStatus(conn.name, false, e);
    }
1264834
private void releaseConnection()
   {
      if (m_rs != null)
      {
         try
         {
            m_rs.close();
         }

         catch (SQLException ex)
         {
            // silently ignore errors on close
         }

         m_rs = null;
      }

      if (m_ps != null)
      {
         try
         {
            m_ps.close();
         }

         catch (SQLException ex)
         {
            // silently ignore errors on close
         }

         m_ps = null;
      }
   }
181296
public static function handle(CommunicationException $exception)
    {
        if ($exception->shouldResetConnection()) {
            $connection = $exception->getConnection();

            if ($connection->isConnected()) {
                $connection->disconnect();
            }
        }

        throw $exception;
    }
677021
public function handleConnect()
    {
        $socket = @stream_socket_accept($this->socket);

        if ($socket === false)
        {
            $this->emit('error', [ $this, new ReadException('Socket could not accept new connection.') ]);
            return;
        }

        $client = null;
        $ex = null;

        try
        {
            $client = $this->createClient($socket, [
                'ssl' => $this->config['ssl'],
                'ssl_method' => $this->config['ssl_method'],
            ]);

            $this->emit('connect', [ $this, $client ]);
        }
        catch (Error $ex)
        {}
        catch (Exception $ex)
        {}

        if ($ex !== null)
        {
            $this->handleDisconnect($socket);
            $this->emit('error', [ $this, new ReadException('Socket could not wrap new connection!') ]);
        }
    }
330898
public function failConnect(FailedConnectionEvent $args)
    {
        $e = $args->getException();
        $this->logger->debug($e->getMessage(), ['event' => 'exception', 'exception' => $e]);

        throw new DatabaseConnectionException($args->getDriver()->getName(), $e->getMessage(), $e);
    }
58666
public function connect($host, $port, Connection $connection, $timeout = 5)
    {
        if ($this->isConnected || $this->isConnecting) {
            return new RejectedPromise(new \LogicException('The client is already connected.'));
        }

        $this->isConnecting = true;
        $this->isConnected = false;

        $this->host = $host;
        $this->port = $port;

        $deferred = new Deferred();

        $this->establishConnection($this->host, $this->port, $timeout)
            ->then(function (DuplexStreamInterface $stream) use ($connection, $deferred, $timeout) {
                $this->stream = $stream;

                $this->emit('open', [$connection, $this]);

                $this->registerClient($connection, $timeout)
                    ->then(function (ConnectResponsePacket $responsePacket) use ($deferred, $connection) {
                        $this->isConnecting = false;
                        $this->isConnected = true;
                        $this->connection = $connection;

                        $this->emit('connect', [$responsePacket, $this]);
                        $deferred->resolve($responsePacket);
                    })
                    ->otherwise(function (\Exception $e) use ($deferred, $connection) {
                        $this->isConnecting = false;

                        $this->emitError($e);
                        $deferred->reject($e);

                        if ($this->stream !== null) {
                            $this->stream->close();
                        }

                        $this->emit('close', [$connection, $this]);
                    });
            })
            ->otherwise(function (\Exception $e) use ($deferred) {
                $this->isConnecting = false;

                $this->emitError($e);
                $deferred->reject($e);
            });

        return $deferred->promise();
    }
276093
private function forceConnect()
    {
        try {
            $command = new \MongoDB\Driver\Command(['ping' => 1]);
            $this->manager->executeCommand('db', $command);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e);
        }
    }
1321284
@Override
    public void addConnectionListener(SICoreConnectionListener listener)
                    throws SIConnectionDroppedException,
                    SIConnectionUnavailableException {

        checkValid();

        _delegateConnection.addConnectionListener(listener);

    }
720791
protected function setErrorCallback(ConnectionInterface $connection, callable $callback)
    {
        $connection->setErrorCallback(function ($connection, $exception) use ($callback) {
            \call_user_func($callback, $this, $exception, $connection);
        });
    }
1022467
private void onConnectFailed(){
        LOGGER.info("Socket failed");
        isConnecting = false;
        isConnected = false;
        cleanup();
        synchronized(connectHolder){
            connectHolder.notifyAll();
        }
    }
833361
protected void setConnection(Text line) throws ParseException {
        connection = new ConnectionField();
        connection.strain(line);
        Collections.sort(this.candidates);
    }
395440
private static function isConnectionError(\GuzzleHttp\Exception\RequestException $exception = null)
    {
        return $exception instanceof \GuzzleHttp\Exception\ConnectException;
    }
456115
function reconnect()
    {
        // Connect to MySQL
        // $this->db = new \mysqli($this->config['host'], $this->config['user'], $this->config['password'], $this->config['dbname'], $this->config['port']);
        $db = \mysqli_init();
        if ( !$db->options(MYSQLI_OPT_CONNECT_TIMEOUT, $this->config['timeout']) ) {
            \throw_error('Setting MYSQLI_OPT_CONNECT_TIMEOUT failed', $db->errno);
        }

        if ( !$db->real_connect($this->config['host'], $this->config['user'], $this->config['password'], $this->config['dbname'], $this->config['port']) ) {
            \throw_error('Can not real_connect to MySQL server, message: ' . $db->connect_error);
        }

        if ($db->connect_errno) {
            \throw_error('Can not connect to MySQL server, message: ' . $db->connect_error, $db->errno);
        }

        // Set charset
        $db->set_charset(isset($this->config['charset']));

        $this->db = $db;
    }