Creates a new {@link JedisPool}, with specified database and default
timeout.

@param hostAndPort
@param password
@param db
@return
@since 0.7.0
543474
public static JedisPool newJedisPool(String hostAndPort, String password, int db) {
        return newJedisPool(hostAndPort, password, db, DEFAULT_TIMEOUT_MS);
    }
130952
public String migrate(String host, int port, Object key, int destinationDb, int timeout) {
		Jedis jedis = getJedis();
		try {
			return jedis.migrate(valueToBytes(host), port, keyToBytes(key), destinationDb, timeout);
		}
		finally {close(jedis);}
	}
436751
public static JedisPool newJedisPool(String hostAndPort, String password) {
        return newJedisPool(defaultJedisPoolConfig(), hostAndPort, password);
    }
23148
public PooledConnection getPooledConnection(String user, String password) throws SQLException {
    return new PGPooledConnection(getConnection(user, password), defaultAutoCommit);
  }
642753
@Override
  public Transport newInstance(final String hostAddress,
                               final int port,
                               final EStage<TransportEvent> clientStage,
                               final EStage<TransportEvent> serverStage,
                               final int numberOfTries,
                               final int retryTimeout) {
    try {
      TcpPortProvider tcpPortProvider = Tang.Factory.getTang().newInjector().getInstance(TcpPortProvider.class);
      return newInstance(hostAddress, port, clientStage,
              serverStage, numberOfTries, retryTimeout, tcpPortProvider);
    } catch (final InjectionException e) {
      throw new RuntimeException(e);
    }
  }
1034695
public static CassandraThriftFacade forSeedsAndPort(String seeds, int defaultPort) {
        final String seed = seeds.contains(",") ? seeds.substring(0, seeds.indexOf(',')) : seeds;
        HostAndPort host = HostAndPort.fromString(seed).withDefaultPort(defaultPort);
        return new CassandraThriftFacade(new TFramedTransport(new TSocket(host.getHostText(), host.getPort())));
    }
1066405
public static JedisPool create(final PippoSettings settings) {
        String host = settings.getString(HOST, Protocol.DEFAULT_HOST).trim();
        int minIdle = settings.getInteger(MIN_IDLE, GenericObjectPoolConfig.DEFAULT_MIN_IDLE);
        int maxIdle = settings.getInteger(MAX_IDLE, GenericObjectPoolConfig.DEFAULT_MAX_IDLE);
        int maxTotal = settings.getInteger(MAX_TOTAL, GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMinIdle(minIdle);
        config.setMaxIdle(maxIdle);
        config.setMaxTotal(maxTotal);

        try {
            return new JedisPool(config, new URI(host));
        } catch (URISyntaxException e) {
            throw new PippoRuntimeException("Malformed redis URI", e);
        }
    }
136429
def create_jdbc_connection_pool(name, server=None, **kwargs):
    '''
    
    '''
    defaults = {
        'allowNonComponentCallers': False,
        'associateWithThread': False,
        'connectionCreationRetryAttempts': '0',
        'connectionCreationRetryIntervalInSeconds': '10',
        'connectionLeakReclaim': False,
        'connectionLeakTimeoutInSeconds': '0',
        'connectionValidationMethod': 'table',
        'datasourceClassname': '',
        'description': '',
        'driverClassname': '',
        'failAllConnections': False,
        'idleTimeoutInSeconds': '300',
        'initSql': '',
        'isConnectionValidationRequired': False,
        'isIsolationLevelGuaranteed': True,
        'lazyConnectionAssociation': False,
        'lazyConnectionEnlistment': False,
        'matchConnections': False,
        'maxConnectionUsageCount': '0',
        'maxPoolSize': '32',
        'maxWaitTimeInMillis': 60000,
        'name': name,
        'nonTransactionalConnections': False,
        'ping': False,
        'poolResizeQuantity': '2',
        'pooling': True,
        'resType': '',
        'sqlTraceListeners': '',
        'statementCacheSize': '0',
        'statementLeakReclaim': False,
        'statementLeakTimeoutInSeconds': '0',
        'statementTimeoutInSeconds': '-1',
        'steadyPoolSize': '8',
        'target': 'server',
        'transactionIsolationLevel': '',
        'validateAtmostOncePeriodInSeconds': '0',
        'validationClassname': '',
        'validationTableName': '',
        'wrapJdbcObjects': True
    }

    # Data = defaults + merge kwargs + poolname
    data = defaults
    data.update(kwargs)

    # Check resType against acceptable values
    if data['resType'] not in (
            'javax.sql.DataSource',
            'javax.sql.XADataSource',
            'javax.sql.ConnectionPoolDataSource',
            'java.sql.Driver'
       ):
        raise CommandExecutionError('Invalid resource type')

    # Check connectionValidationMethod against acceptable velues
    if data['connectionValidationMethod'] not in (
            'auto-commit',
            'meta-data',
            'table',
            'custom-validation'
       ):
        raise CommandExecutionError('Invalid connection validation method')

    if data['transactionIsolationLevel'] \
       and data['transactionIsolationLevel'] not in (
               'read-uncommitted',
               'read-committed',
               'repeatable-read',
               'serializable'
       ):
        raise CommandExecutionError('Invalid transaction isolation level')

    if not data['datasourceClassname'] \
       and data['resType'] in (
               'javax.sql.DataSource',
               'javax.sql.ConnectionPoolDataSource',
               'javax.sql.XADataSource'
       ):
        raise CommandExecutionError('No datasource class name while using datasource resType')
    if not data['driverClassname'] and data['resType'] == 'java.sql.Driver':
        raise CommandExecutionError('No driver class nime while using driver resType')

    return _create_element(name, 'resources/jdbc-connection-pool', data, server)
646658
public static AzkabanDataSource getMySQLDataSource(final String host, final Integer port,
      final String dbName, final String user, final String password, final Integer numConnections) {
    return new MySQLBasicDataSource(host, port, dbName, user, password,
        numConnections);
  }
116847
public static ShardedJedisPool newJedisPool(String hostsAndPorts, String password) {
        return newJedisPool(hostsAndPorts, password, DEFAULT_TIMEOUT_MS);
    }
603897
public Connection createConnection(String url, String username, String password) throws SQLException {

		if (connection != null && !connection.isClosed())
			return connection;

		connection = DriverManager.getConnection(url, username, password);
		return connection;
	}
864215
public static String buildQuorum(List<HostAndPort> hostAndPorts, int defaultPort) {
    List<String> entries = new ArrayList<String>(hostAndPorts.size());
    for (HostAndPort hostAndPort : hostAndPorts) {
      entries.add(buildQuorumEntry(hostAndPort, defaultPort));
    }
    return JstormYarnUtils.join(entries, ",", false);
  }
1314142
protected ObjectPool setupPool(JdbcConnectionDescriptor jcd)
    {
        log.info("Create new ObjectPool for DBCP connections:" + jcd);

        try
        {
            ClassHelper.newInstance(jcd.getDriver());
        }
        catch (InstantiationException e)
        {
            log.fatal("Unable to instantiate the driver class: " + jcd.getDriver() + " in ConnectionFactoryDBCImpl!" , e);
        }
        catch (IllegalAccessException e)
        {
            log.fatal("IllegalAccessException while instantiating the driver class: " + jcd.getDriver() + " in ConnectionFactoryDBCImpl!" , e);
        }
        catch (ClassNotFoundException e)
        {
            log.fatal("Could not find the driver class : " + jcd.getDriver() + " in ConnectionFactoryDBCImpl!" , e);
        }

        // Get the configuration for the connection pool
        GenericObjectPool.Config conf = jcd.getConnectionPoolDescriptor().getObjectPoolConfig();

        // Get the additional abandoned configuration
        AbandonedConfig ac = jcd.getConnectionPoolDescriptor().getAbandonedConfig();

        // Create the ObjectPool that serves as the actual pool of connections.
        final ObjectPool connectionPool = createConnectionPool(conf, ac);

        // Create a DriverManager-based ConnectionFactory that
        // the connectionPool will use to create Connection instances
        final org.apache.commons.dbcp.ConnectionFactory connectionFactory;
        connectionFactory = createConnectionFactory(jcd);

        // Create PreparedStatement object pool (if any)
        KeyedObjectPoolFactory statementPoolFactory = createStatementPoolFactory(jcd);

        // Set validation query and auto-commit mode
        final String validationQuery;
        final boolean defaultAutoCommit;
        final boolean defaultReadOnly = false;
        validationQuery = jcd.getConnectionPoolDescriptor().getValidationQuery();
        defaultAutoCommit = (jcd.getUseAutoCommit() != JdbcConnectionDescriptor.AUTO_COMMIT_SET_FALSE);

        //
        // Now we'll create the PoolableConnectionFactory, which wraps
        // the "real" Connections created by the ConnectionFactory with
        // the classes that implement the pooling functionality.
        //
        final PoolableConnectionFactory poolableConnectionFactory;
        poolableConnectionFactory = new PoolableConnectionFactory(connectionFactory,
                connectionPool,
                statementPoolFactory,
                validationQuery,
                defaultReadOnly,
                defaultAutoCommit,
                ac);
        return poolableConnectionFactory.getPool();
    }
1060124
public Database get_db_obj(final String host, final String port) throws DevFailed {
        if (ApiUtil.getOrb() == null) {
            create_orb();
        }

        // If first time, create vector
        if (db_list == null) {
            db_list = new ArrayList<Database>();
        }

        // Build tango_host string
        final String tango_host = host + ":" + port;

        // Search if database object already created for this host and port
        if (defaultDatabase != null) {
            if (defaultDatabase.get_tango_host().equals(tango_host)) {
                return defaultDatabase;
            }
        }

        for (final Database dbase : db_list) {
            if (dbase.get_tango_host().equals(tango_host)) {
                return dbase;
            }
        }

        // Else, create a new database object
        final Database dbase = new Database(host, port);
        db_list.add(dbase);
        return dbase;
    }
246936
public static ShardedJedisPool newShardedJedisPool(JedisPoolConfig poolConfig,
            String hostsAndPorts, int timeoutMs) {
        return newShardedJedisPool(poolConfig, hostsAndPorts, null, timeoutMs);
    }
261252
public static void configureExample(String host, int port, String user, String password, Authentication authType)
    throws IOException, ResourceNotFoundException, ForbiddenUserException, FailedRequestException, ResourceNotResendableException
  {
    // create the client
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    installResourceExtension(client);

    configureQueryOptions(client);

    setUpExample(client);

    // release the client
    client.release();
  }
691434
@SuppressWarnings("unused")
    public static Query createWithTimeout(Service service, Domain domain, int timeout) {
        return new Query(service, domain, timeout);
    }