import java.io.IOException;
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.client.HBaseAdmin;
public class CreateTable {
public static void main(String[] args) throws IOException {
Configuration con = HBaseConfiguration.create();
HBaseAdmin admin = new HBaseAdmin(con);
HTableDescriptor ht = new HTableDescriptor("emp");
ht.addFamily(new HColumnDescriptor("add"));
ht.addFamily(new HColumnDescriptor("dept"));
admin.createTable(ht);
System.out.println("Table Created");
}
}
I have used the above code to create Hbase table. I have downloaded all the Jars which are required and added them as an when am getting errors. But still am getting lots of errors related to zookeeper. My doubt is, do I have to Zookeeper connection using JAVA API before creating the table. And am using JDK 1.8 Please guide me the exact procedure in creating the table in Hbase using JAVA API. These are the below errors am getting with Zookeeper, but I have added the Zookeeper Jar. 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:zookeeper.version=3.3.1-942149, built on 05/07/2010 17:14 GMT 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:host.name=quickstart.cloudera 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:java.version=1.8.0_144 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:java.vendor=Oracle Corporation 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:java.home=/home/cloudera/jdk1.8.0_144/jre 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:java.class.path=/home/cloudera/workspace/HbaseTbl/bin:/home/cloudera/Downloads/apache-logging-log4j.jar:/home/cloudera/Downloads/hadoop-core-0.20.2-cdh3u0.jar:/home/cloudera/Downloads/hbase-0.94.0.jar:/home/cloudera/Downloads/org-apache-commons-logging.jar:/home/cloudera/Downloads/zookeeper.jar 17/12/11 12:44:10 INFO zookeeper.ZooKeeper: Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib