Get a MPConnection from the cache

@param conn The MEConnection for which we want a MPConnection for
@return the MPConnection
5224
public MPConnection getMPConnection(MEConnection conn)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getMPConnection", new Object[] { conn });

    MPConnection mpConn;
    synchronized(_mpConnectionsByMEConnection)
    {
      //look up the MPConnection based on the MEConnection
      mpConn = _mpConnectionsByMEConnection.get(conn);      
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getMPConnection", mpConn);
  
    return mpConn;
  }
411427
def _get_conn():
    '''
    
    '''
    try:
        conn = psycopg2.connect(
               host=__opts__['master_job_cache.postgres.host'],
               user=__opts__['master_job_cache.postgres.user'],
               password=__opts__['master_job_cache.postgres.passwd'],
               database=__opts__['master_job_cache.postgres.db'],
               port=__opts__['master_job_cache.postgres.port'])
    except psycopg2.OperationalError:
        log.error('Could not connect to SQL server: %s', sys.exc_info()[0])
        return None
    return conn
1081610
public static synchronized AccountManager getInstance(XMPPConnection connection) {
        AccountManager accountManager = INSTANCES.get(connection);
        if (accountManager == null) {
            accountManager = new AccountManager(connection);
            INSTANCES.put(connection, accountManager);
        }
        return accountManager;
    }
882900
public static NClob createNClob(final Connection conn) {
		try {
			return conn.createNClob();
		} catch (SQLException e) {
			throw new UroborosqlRuntimeException(e);
		}
	}
1188973
public <R> Connection<CL> getConnectionForOperation(BaseOperation<CL, R> baseOperation) {
	return selectionStrategy.getConnection(baseOperation, cpConfiguration.getMaxTimeoutWhenExhausted(),
		TimeUnit.MILLISECONDS);
    }
415893
protected Connection getConnection(InetSocketAddress address) {
        Connection conn = null;
        try {
            // 获取连接
            conn = pool.borrowObject(address);
        } catch (FdfsException e) {
            throw e;
        } catch (Exception e) {
            LOGGER.error("Unable to borrow buffer from pool", e);
            throw new RuntimeException("Unable to borrow buffer from pool", e);
        }
        return conn;
    }
58886
public MPConnection findMPConnection(SIBUuid8 remoteUuid)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "findMPConnection", new Object[] { remoteUuid });

    //try to get an MPConnection from our cache
    MPConnection mpConn = getMPConnection(remoteUuid);
    //if we didn't have one in the cache then ask TRM
    if(remoteUuid!= null && mpConn == null && _routingManager != null)
    {
      //ask TRM for a MEConnection to the given cellule ... for JS1 there should only be 0 or 1
      MEConnection[] choices = _routingManager.listConnections(new MessagingEngine(remoteUuid));
      if(choices != null && choices.length > 0 && choices[0] != null)
      {
        if(choices.length > 1)
        {
          //for JS1, if we get back more than one possible connection to a cellule then
          //we are in trouble so throw an exception ... shouldn't happen!!
          SIMPErrorException e = new SIMPErrorException(
              nls.getFormattedMessage(
                "INTERNAL_MESSAGING_ERROR_CWSIP0005",
                new Object[] {
                  "com.ibm.ws.sib.processor.io.MPIO",
                  "1:378:1.32",
                  this},
                null));
          
          FFDCFilter.processException(
            e,
            "com.ibm.ws.sib.processor.io.MPIO.findMPConnection",
            "1:385:1.32",
            this);
            
          if(TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
             SibTr.exception(tc, e); 
          if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "findMPConnection");
          
          throw e;
        }
        
        //if we were given a new MEConnection to use ... find or create
        //a MPConnection for it
        mpConn = getOrCreateNewMPConnection(remoteUuid, choices[0]);
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "findMPConnection", mpConn);
    
    //return the MPConnection
    return mpConn;
  }
137350
public OTMConnection acquireConnection(PBKey pbkey)
	{
		Util.log("In JCAKit.getConnection,1");
		try
		{
			OTMConnectionRequestInfo info = new OTMConnectionRequestInfo(pbkey);
			return (OTMConnection) m_connectionManager.allocateConnection(m_managedConnectionFactory, info);
		}
		catch (ResourceException ex)
		{
			throw new OTMConnectionRuntimeException(ex);
		}
	}
1045003
@Override
    public Connection getConnection(String dsName, boolean startTransaction) {
        return jdbcHelper.getConnection(dsName, startTransaction);
    }
708524
protected Stream<T> getAll(Connection conn) {
        return executeSelectAsStream(rowMapper, conn, true, calcSqlSelectAll());
    }
605536
public MPConnection getMPConnection(SIBUuid8 remoteUuid)
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "getMPConnection", new Object[] { remoteUuid });

    MPConnection mpConn;
    synchronized(_mpConnectionsByMEConnection)
    {
      //look up the MPConnection based on the cellule
      mpConn = _mpConnectionsByMEUuid.get(remoteUuid);      
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "getMPConnection", mpConn);
    
    //return the MPConnection
    return mpConn;
  }
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);
        }
    }
140787
public XAConnection getXAConnection() throws SQLException {

        // Comment out before public release:
        System.err.print("Executing " + getClass().getName()
                         + ".getXAConnection()...");

        try {
            Class.forName(driver).newInstance();
        } catch (ClassNotFoundException e) {
            throw new SQLException("Error opening connection: "
                                   + e.getMessage());
        } catch (IllegalAccessException e) {
            throw new SQLException("Error opening connection: "
                                   + e.getMessage());
        } catch (InstantiationException e) {
            throw new SQLException("Error opening connection: "
                                   + e.getMessage());
        }

        JDBCConnection connection =
            (JDBCConnection) DriverManager.getConnection(url, connProperties);

        // Comment out before public release:
        System.err.print("New phys:  " + connection);

        JDBCXAResource xaResource = new JDBCXAResource(connection, this);
        JDBCXAConnectionWrapper xaWrapper =
            new JDBCXAConnectionWrapper(connection, xaResource,
                                        connectionDefaults);
        JDBCXAConnection xaConnection = new JDBCXAConnection(xaWrapper,
            xaResource);

        xaWrapper.setPooledConnection(xaConnection);

        return xaConnection;
    }
91053
public final Connection getConnection(final String dataSourceName) throws SQLException {
        return getConnections(ConnectionMode.MEMORY_STRICTLY, dataSourceName, 1).get(0);
    }
214201
@SuppressWarnings("unchecked")
    public static <T> T connectCache(Runnable runnable, Object cachedValue) {
        THREAD_LOCAL.set(Optional.fromNullable(cachedValue));
        @Cleanup QuietCloseable i = () -> THREAD_LOCAL.remove();

        runnable.run();
        return (T) THREAD_LOCAL.get().orNull();
    }
804705
public static synchronized CarbonManager getInstanceFor(XMPPConnection connection) {
        CarbonManager carbonManager = INSTANCES.get(connection);

        if (carbonManager == null) {
            carbonManager = new CarbonManager(connection);
            INSTANCES.put(connection, carbonManager);
        }

        return carbonManager;
    }
753440
private Connection getConnection(final ICommandLine cl) throws SQLException, InstantiationException, IllegalAccessException,
            ClassNotFoundException {
        String database = DEFAULT_TABLE;
        if (cl.hasOption("database")) {
            database = cl.getOptionValue("database");
        }
        String hostname = DEFAULT_HOSTNAME;
        if (cl.hasOption("hostname") && !"".equals(cl.getOptionValue("hostname"))) {
            hostname = cl.getOptionValue("hostname");
        }
        String port = DEFAULT_PORT;
        if (cl.hasOption("port") && !"".equals(cl.getOptionValue("port"))) {
            port = cl.getOptionValue("port");
        }
        String password = "";
        if (cl.hasOption("password")) {
            password = cl.getOptionValue("password");
        }
        String username = "";
        if (cl.hasOption("logname")) {
            username = cl.getOptionValue("logname");
        }
        String timeout = DEFAULT_TIMEOUT;
        if (cl.getOptionValue("timeout") != null) {
            timeout = cl.getOptionValue("timeout");
        }
        Properties props = new Properties();
        props.setProperty("user", username);
        props.setProperty("password", password);
        props.setProperty("timeout", timeout);
        String url = "jdbc:postgresql://" + hostname + ":" + port + "/" + database;
        DriverManager.registerDriver((Driver) Class.forName("org.postgresql.Driver").newInstance());
        return DriverManager.getConnection(url, props);
    }