create table in Hbase using Java API

0 votes

I am trying to create one table inside Hbase using Java API. I configured all the settings in Hbase. Can somebody share, how to create table using Java API?

Mar 31 in Big Data Hadoop by akhtar
• 28,180 points
236 views

1 answer to this question.

0 votes

Hi@akhtar,

You can use the below code to create table in Hbase.

import java.io.IOException;

import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.TableName;

import org.apache.hadoop.conf.Configuration;

public class CreateTable1 {

public static void main(String[] args) throws IOException {

Configuration con = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(con);
HTableDescriptor tableDescriptor = new
HTableDescriptor(TableName.valueOf("table name"));

tableDescriptor.addFamily(new HColumnDescriptor("data1"));
tableDescriptor.addFamily(new HColumnDescriptor("data2"));
admin.createTable(tableDescriptor);
System.out.println(" Table Created");
  }
}

write this java code inside one file and run the file.

$ javac filename.java
$ java filename

Thank You

answered Mar 31 by MD
• 65,360 points

Related Questions In Big Data Hadoop

0 votes
1 answer

How to create new directory in hdfs using java code?

Try this: { Configuration config ...READ MORE

answered Dec 6, 2018 in Big Data Hadoop by Omkar
• 69,030 points
1,128 views
0 votes
1 answer

How to create a Table using HBase shell ?

Hey, You can create a table using the create command, ...READ MORE

answered May 23, 2019 in Big Data Hadoop by Gitika
• 41,360 points
179 views
0 votes
1 answer

How to Create a table with region replication in Hbase?

Hi, Region replication is a per-table property. All ...READ MORE

answered May 31, 2019 in Big Data Hadoop by Gitika
• 41,360 points
358 views
0 votes
1 answer

How to create smaller table from big table in HIVE?

You could probably best use Hive's built-in sampling ...READ MORE

answered Sep 24, 2018 in Big Data Hadoop by digger
• 26,680 points
558 views
0 votes
1 answer
0 votes
1 answer

Moving files in Hadoop using the Java API?

I would recommend you to use FileSystem.rename(). ...READ MORE

answered Apr 15, 2018 in Big Data Hadoop by Shubham
• 13,450 points
1,523 views
0 votes
1 answer

Hadoop giving java.io.IOException, in mkdir Java code.

I am not sure about the issue. ...READ MORE

answered May 3, 2018 in Big Data Hadoop by Shubham
• 13,450 points
1,015 views
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 10,950 points
6,088 views
0 votes
1 answer

How to create table in cassandra?

Hi@akhtar, To create table in cassandra, you have ...READ MORE

answered Apr 1 in Big Data Hadoop by MD
• 65,360 points
55 views
0 votes
1 answer

Error: Could not create the Java Virtual Machine in Hadoop.

Hi@akhtar, You can list down all the files ...READ MORE

answered 6 days ago in Big Data Hadoop by MD
• 65,360 points
17 views