Replaces the owl connection with a new one
Called when the user cancels a query. Easier to get a new connection, than waiting for the cancel
@return The old connection: The caller must close this connection
335071
public OWLConnection replaceConnection() throws OntopConnectionException {
        OWLConnection oldconn = this.owlConnection;
        owlConnection = reasoner.getConnection();
        return oldconn;
    }
704994
def get_new_connection(self, conn_params):
        """"""
        connection = ldap.ldapobject.ReconnectLDAPObject(
            uri=conn_params['uri'],
            retry_max=conn_params['retry_max'],
            retry_delay=conn_params['retry_delay'],
            bytes_mode=False)

        options = conn_params['options']
        for opt, value in options.items():
            if opt == 'query_timeout':
                connection.timeout = int(value)
            elif opt == 'page_size':
                self.page_size = int(value)
            else:
                connection.set_option(opt, value)

        if conn_params['tls']:
            connection.start_tls_s()

        connection.simple_bind_s(
            conn_params['bind_dn'],
            conn_params['bind_pw'],
        )
        return connection
1194917
protected function getConnection() {
        if (count($this->pool) > 0) {
            /**
             * @var $connection RedisConnection
             */
            foreach ($this->pool as $k => $connection) {
                unset($this->pool[$k]);
                break;
            }
            return $connection;
        } else {
            return new RedisConnection($this);
        }
    }
1318920
public Connection getConnection() throws FetchException {
        try {
            if (mOpenConnections == null) {
                throw new FetchException("Repository is closed");
            }

            JDBCTransaction txn = localTransactionScope().getTxn();
            if (txn != null) {
                // Return the connection used by the current transaction.
                return txn.getConnection();
            }

            // Get connection outside lock section since it may block.
            Connection con = mDataSource.getConnection();
            con.setAutoCommit(true);

            mOpenConnectionsLock.lock();
            try {
                if (mOpenConnections == null) {
                    con.close();
                    throw new FetchException("Repository is closed");
                }
                mOpenConnections.put(con, null);
            } finally {
                mOpenConnectionsLock.unlock();
            }

            return con;
        } catch (Exception e) {
            throw toFetchException(e);
        }
    }
651596
function Connection(conn) {
	if(!(this instanceof Connection)) {
		return new Connection(conn);
	}
	var self = this;
	if(!conn) { throw new TypeError("no connection set"); }
	self._connection = conn;
	self._connect    = Q.nfbind(self._connection.connect.bind(self._connection));
	self._query      = Q.nfbind(self._connection.query.bind(self._connection));

	// These do not have callbacks when PoolConnection is used
	//self._end        = Q.nfbind(self._connection.end.bind(self._connection));
	//self._release        = Q.nfbind(self._connection.release.bind(self._connection));

	self._changeUser = Q.nfbind(self._connection.changeUser.bind(self._connection));
	db.Connection.call(self, conn);
}
794877
public void returnConnection(DataConnection connection) {
        if (connection.isUsable()) {
            connection.setLastUsage(new Date());
            availableConnections.add(connection);
        }
        else {
            connection.close();
        }

        usedConnections.remove(connection);
    }
552376
def clientConnectionLost(self, connector, reason):
        
        if not isinstance(reason.value, error.ConnectionDone):
            _legacy_twisted_log.msg(
                "Lost connection to the AMQP broker ({reason})",
                reason=reason.value,
                logLevel=logging.WARNING,
            )
        if self._client_ready.called:
            # Renew the ready deferred, it will callback when the
            # next connection is ready.
            self._client_ready = defer.Deferred()
        protocol.ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
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;
    }
739775
static ConnectionRequest wrap(ConnectionRequest orig) {
        if (orig instanceof Wrapped)
            throw new IllegalArgumentException();
        return (ConnectionRequest) Proxy.newProxyInstance(
                // https://github.com/aws/aws-sdk-java/pull/48#issuecomment-29454423
                ClientConnectionRequestFactory.class.getClassLoader(),
                interfaces,
                new Handler(orig));
    }
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;
	}
1130877
public SICoreConnection getSICoreConnection()
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(this, tc, "getSICoreConnection");
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(this, tc, "getSICoreConnection", siCoreConnection);
      return siCoreConnection;
   }
469840
private CuratorFramework getNewCuratorClient() {
    CuratorFramework client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
        (int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
        (int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
        new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
    client.start();

    // Sometimes, if the master crashes and restarts too quickly (faster than the zookeeper
    // timeout), zookeeper thinks the new client is still an old one. In order to ensure a clean
    // state, explicitly close the "old" client and recreate a new one.
    client.close();
    client = CuratorFrameworkFactory.newClient(mZookeeperAddress,
        (int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_SESSION_TIMEOUT),
        (int) ServerConfiguration.getMs(PropertyKey.ZOOKEEPER_CONNECTION_TIMEOUT),
        new ExponentialBackoffRetry(Constants.SECOND_MS, 3));
    client.start();
    return client;
  }
369218
def connection(self):
        
        
        self._condition.acquire()
        try:
            if (self._maxconnections and self._connections >= self._maxconnections):
                raise TooManyConnections("%d connections are already equal to the max: %d" % (self._connections, self._maxconnections))
            # connection limit not reached, get a dedicated connection
            try: # first try to get it from the idle cache
                con = self._idle_cache.pop(0)
            except IndexError: # else get a fresh connection
                con = self.new_connection()
            self._connections += 1
        finally:
            self._condition.release()
        return con
1220990
void replaceConnection(ConnectionWrapper connWrap) {
		synchronized (allConnections) {
			try {
				if (usedConnections.remove(connWrap)) {
					nrofReset++;

					//the object was indeed locked
					allConnections.remove(connWrap);
					//IMPORTANT does this result in an SQL error which breaks off the connection?
					connWrap.getConnection().close();
					System.out.println(new LogEntry(Level.CRITICAL, "Connection reset" + (connWrap.getLastStatement() != null ? " while executing '" + connWrap.getLastStatement() + '\'' : "")));
					//lets create a fresh successor
					ConnectionWrapper newConnWrap = createConnectionWrapper(dbUrl, dbUsername, dbUserpassword);
					availableConnections.add(newConnWrap);
					allConnections.add(newConnWrap);
				} else {
					nrofErrors++;
					System.out.println(new LogEntry(Level.CRITICAL, "error in connection pool: attempt to close a Connection that does not exist in pool"));
				}
			} catch (SQLException sqle) {
				//happens if db unreachable
				//connection will be lost for the time being
				nrofErrors++;
				System.out.println(new LogEntry(Level.CRITICAL, "can not create new connection to " + dbUrl + " unreachable or useless connection settings", sqle));
			}
			try {
				if (!connWrap.isClosed()) {
					connWrap.getConnection().close();
				}
			} catch (SQLException sqle) {
				nrofErrors++;
				System.out.println(new LogEntry(Level.CRITICAL, "", sqle));
			}
		}
	}
1337547
@Override
	public void cleanupConnection(ConnectionHandle oldHandle, ConnectionHandle newHandle) {
		this.threadFinalizableRefs.remove(oldHandle);
		this.threadWatch(newHandle);
	}
226425
@Override
  public Connection<T> newConnection(final Identifier destId) {
    final Connection<T> connection = connectionMap.get(destId);

    if (connection == null) {
      final Connection<T> newConnection = new NetworkConnection<>(this, destId);
      connectionMap.putIfAbsent(destId, newConnection);
      return connectionMap.get(destId);
    }
    return connection;
  }
1309202
public Connection getConnection() throws SQLException {
        try {
            return new DrizzleConnection(new MySQLProtocol(hostname, port, database, null, null, new Properties()),
                    new DrizzleQueryFactory());
        } catch (QueryException e) {
            throw SQLExceptionMapper.get(e);
        }
    }