[Hbase]eclipse Operation Hbase

Source: Internet
Author: User
Tags zookeeper

Ubuntu14.04,eclipse operation of HBase. The following is a example that uses the HBase Java API to manipulate hbase to view the student1 column families in HBase:

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;import Org.apache.hadoop.hbase.util.bytes;public class Operatetable {public static void main (string[] args) throws Ioexce                  ption {Configuration conf = hbaseconfiguration.create ();                  Conf.set ("Hbase.zookeeper.quorum", "localhost");//You must add this when using Eclipse, or you cannot locate it. After a parameter write address, I here is pseudo-distributed, so for localhost                  Conf.set ("Hbase.zookeeper.property.clientPort", "2181"); Hbaseadmin admin = new hbaseadmin (conf);//Create a new database administrator htabledescriptor Tabledescriptor = Admin.gettablede                  Scriptor (Bytes.tobytes ("Student1"));                  byte[] name = Tabledescriptor.getname ();                  SYSTEM.OUT.PRINTLN ("Result:"); System.out.println("Table name:" + new String (name));                  hcolumndescriptor[] columnfamilies = tabledescriptor. Getcolumnfamilies (); for (Hcolumndescriptor d:columnfamilies) {System.out.println ("column families:" + D.getnamea                          Sstring ()); }            }}


[Hbase]eclipse Operation Hbase

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.