Error: the constructor htable (configuration string) is deprecated

htable deprecated
tabledescriptorbuilder example
how to retrieve data from hbase using java
hbase tablename example
hbase create table
hbase put example java
java hbase library

I am using CDH 5.4.2 and trying to create Hbase Table have the following code snippet:

     Configuration conf = HBaseConfiguration.create(new Configuration());
        HBaseAdmin hba = new <strike>HBaseAdmin</strike>(conf);
            HTableDescriptor ht = new      <strike>HTableDescriptor</strike>    (args[0]);
            ht.addFamily(new HColumnDescriptor("sample"));

There is a Deprecated error.

  • How to avoid these warnings?
  • Do I need to add any specific jars for CDH 5.4.2?

It's just a warning. But you should not use deprecated methods in your code.

In place of :

HBaseAdmin admin = new HBaseAdmin(conf);

You should use:

Connection conn =ConnectionFactory.createConnection(conf);
Admin admin  = conn.getAdmin();

the constructor htable (configuration string) is deprecated - iOS, Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; public class HBaseSample { public static void main(String[] args) { Configuration conf  Stack Overflow Public questions and The above statement gives the htable descriptor as deprecated. the constructor htable (configuration string) is deprecated.

Sample code for your reference. Assuming that you have Hbase running in standalone mode.

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

public class HBaseSample {

    public static void main(String[] args) {
        Configuration conf = HBaseConfiguration.create();
        try {           
            Connection conn = ConnectionFactory.createConnection(conf);
            Admin hAdmin = conn.getAdmin();

            HTableDescriptor hTableDesc = new HTableDescriptor(
            hTableDesc.addFamily(new HColumnDescriptor("name"));
            hTableDesc.addFamily(new HColumnDescriptor("contactinfo"));
            hTableDesc.addFamily(new HColumnDescriptor("address"));


            System.out.println("Table created Successfully...");

        } catch (Exception e) {

HTable (Apache HBase 1.1.7 API), Modifier, Constructor and Description Constructing HTable objects manually has been deprecated. Please use Configuration conf, String tableName). public static int getInt(org.apache.hadoop.conf.Configuration conf, String name, String deprecatedName, int defaultValue) Get the value of the name property as an int , possibly referring to the deprecated name of the configuration property.

If you need to retrieve a table for usage, you can use Connection.getTable(TableName)

But If you need to create a table instead, use TableDescriptorBuilder and Admin.createTable(TableDescriptor)

For instance:

val tableDescriptor: TableDescriptor = TableDescriptorBuilder


HTableDescriptor (Apache HBase 3.0.0-SNAPSHOT API), Getter for fetching an unmodifiable map. String · getConfigurationValue(String key). Deprecated. Getter for accessing the configuration value by  4 Error: the constructor htable (configuration string) is deprecated Jul 6 '16 3 How to convert csv date format to into mysql db Jul 4 '13 2 Amazon EC2 instance can't update or use yum Jul 16 '19

HTableDescriptor (HBase 0.98.6-cdh5.3.2 API), Modifier, Constructor and Description. HTableDescriptor(). Deprecated. Used by Writables and Writables are going away. HTableDescriptor(byte[] name). Override the default executor pool defined by the hbase.htable.threads.* configuration values. getImplementationClassName @Deprecated public String getImplementationClassName ()

HBaseAdmin (HBase 0.98.6-cdh5.3.1 API), Constructor for externally managed HConnections. Check to see if HBase is running. See HBaseAdmin(HConnection connection) @Deprecated public String[] getTableNames(Pattern pattern) throws Returns: a list of snapshot descriptors for completed snapshots; Throws: IOException - if a network error occurs  HTable is no longer a client API. Use Table instead. It is marked InterfaceAudience.Private indicating that this is an HBase-internal class as defined in Hadoop Interface Classification There are no guarantees for backwards source / binary compatibility and methods or class can change or go away without deprecation.

Migrating from Earlier HBase Versions, In HBase 1.0 and later, instead of relying upon the deprecated HConnection interface, you should use Connection objects are thread-safe. Generates a Configuration instance by applying the ZooKeeper cluster key to the base Configuration. Note that additional configuration properties may be needed for a remote cluster, so it is preferable to use createClusterConf(Configuration, String, String).

  • hAdmin.close() - It is necessary to close the admin
  • Be careful HTableDescriptor is deprecated: As of release 2.0.0, this will be removed in HBase 3.0.0. Use TableDescriptorBuilder to build HTableDescriptor.