# Migrate from earlier HBase versions

The Cloud Bigtable HBase client for Java targets versions 1.x and 2.x of the
[Apache HBase API](https://hbase.apache.org/apidocs/). Version 1.0 of the API included some notable
changes from earlier versions of HBase. If you are migrating to
Bigtable from HBase, and your application targets an older version
of the HBase API, you will need to update your application to make it compatible
with Bigtable.

To assist with your migration, this page summarizes the most notable changes in
the HBase 1.0 API.

## Connection interface

In HBase 1.0 and later, instead of relying upon the deprecated `HConnection`
interface, you should use
[`org.apache.hadoop.hbase.client.ConnectionFactory`](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/ConnectionFactory.html).
This class creates objects that implement the new [`Connection`
interface](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Connection.html). `ConnectionFactory` replaces the deprecated
classes `ConnectionManager` and `HConnectionManager`.

Creating a `Connection` object is a relatively expensive operation. You should
create one `Connection` object per process and share the object as needed.
`Connection` objects are thread-safe.

In addition, be sure to close the connection once you are done using it. In
HBase 1.0 and later, it is the application's responsibility to manage the
lifecycle of the connection.

Your updated code should look similar to the following example:

    Connection connection = ConnectionFactory.createConnection(config);
    // ...
    connection.close();

## TableName class

In previous versions of HBase, when you manipulated a table, you could specify
the table name as a `String` or `byte[]` value. In HBase 1.0 and later, you must
specify the table name by creating an instance of
[`org.apache.hadoop.hbase.TableName`](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/TableName.html):

    String tableName = "MyTable";
        // or byte[] tableName = Bytes.toBytes("MyTable");
    TableName tableNameObj = TableName.valueOf(tableName);

## Table, BufferedMutator, and RegionLocator interfaces

In HBase 1.0, the `HTable` class is replaced by the following interfaces:

- [`org.apache.hadoop.hbase.client.Table`](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Table.html): Enables you to work with data in a single table.
- [`org.apache.hadoop.hbase.client.BufferedMutator`](https://hbase.apache.org/devapidocs/org/apache/hadoop/hbase/client/BufferedMutator.html): Enables you to perform asynchronous batch writes to a table. Use this class instead of calling the `setAutoFlush(boolean)` method in `HTableInterface`.
- [`org.apache.hadoop.hbase.client.RegionLocator`](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/RegionLocator.html): Provides access to information about a table's regions.

> [!NOTE]
> **Note:** You cannot use `new HTable(config)` to access Bigtable.

Use a `Connection` object to obtain an instance of these interfaces:

    Table table = connection.getTable(tableNameObj);
    BufferedMutator mutator = connection.getBufferedMutator(tableNameObj);
    RegionLocator regionLocator = connection.getRegionLocator(tableNameObj);

Instances of `Table`, `BufferedMutator`, and `RegionLocator` are not
thread-safe. However, these are lightweight objects, so you can create them as
needed within the context of a single thread.

## Admin interface

In HBase 1.0, the `HBaseAdmin` class is replaced by the
[`org.apache.hadoop.hbase.client.Admin` interface](https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/client/Admin.html). Because
Bigtable handles maintenance tasks automatically, many of the
methods in the `Admin` interface are not supported. See [Differences between the
HBase and Bigtable APIs](https://docs.cloud.google.com/bigtable/docs/hbase-differences#admin) for details.

> [!NOTE]
> **Note:** You cannot use `new HBaseAdmin(config)` to access Bigtable.

Use a `Connection` object to obtain an instance of the `Admin` interface:

    Admin admin = connection.getAdmin();