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