Configures a connection pool.

## Explore further


For detailed documentation that includes this code sample, see the following:

- [Configure connection pools](https://docs.cloud.google.com/bigtable/docs/configure-connection-pools)

## Code sample

### Java


To learn how to install and use the client library for Bigtable, see
[Bigtable client libraries](https://docs.cloud.google.com/bigtable/docs/reference/libraries).


To authenticate to Bigtable, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).



    import static com.google.cloud.bigtable.hbase.BigtableOptionsFactory.BIGTABLE_DATA_CHANNEL_COUNT_KEY;

    import com.google.cloud.bigtable.hbase.BigtableConfiguration;
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.hbase.client.Connection;

    public class ConfigureConnectionPool {

      public static void configureConnectionPool(String projectId, String instanceId) {
        // String projectId = "my-project-id";
        // String instanceId = "my-instance-id";
        Configuration config = BigtableConfiguration.configure(projectId, instanceId);
        config.setInt(BIGTABLE_DATA_CHANNEL_COUNT_KEY, 10);
        try (Connection connection = BigtableConfiguration.connect(config)) {
          int poolSize = connection.getConfiguration().getInt(BIGTABLE_DATA_CHANNEL_COUNT_KEY, 0);

          System.out.println(String.format("Connected with pool size of %d", poolSize));
        } catch (Exception e) {
          System.out.println("Error during ConfigureConnectionPool: \n" + e.toString());
        }
      }
    }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=bigtable).