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, 2020 in Big Data Hadoop by akhtar
• 38,260 points
1,595 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, 2020 by MD
• 95,460 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,220 points
3,862 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
• 65,770 points
1,041 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 Jun 1, 2019 in Big Data Hadoop by Gitika
• 65,770 points
1,863 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,740 points
1,736 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,490 points
2,669 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,490 points
2,543 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
• 11,380 points
11,028 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, 2020 in Big Data Hadoop by MD
• 95,460 points
635 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 Oct 16, 2020 in Big Data Hadoop by MD
• 95,460 points
2,205 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP