How to use HBase JAVA API
This article mainly introduces how to use HBase JAVA API, the introduction in the article is very detailed, has a certain reference value, interested friends must read!
Maven
Pom.xml
Org.apache.hbase hbase-client 1.3.5 org.apache.hbase hbase-server 1.3.5
Static code block
Private static Connection connection = null; private static Admin admin = null;; static {try {Configuration configuration = HBaseConfiguration.create (); configuration.set ("hbase.zookeeper.quorum", "aliyun:2181"); connection = ConnectionFactory.createConnection (configuration); admin = connection.getAdmin ();} catch (IOException e) {e.printStackTrace () }} create table / / create table public static void createTable (String tableName, String [] cols) throws IOException {TableName table = TableName.valueOf (tableName); if (admin.tableExists (table)) {System.out.println ("table already exists!") ;} else {HTableDescriptor hTableDescriptor = new HTableDescriptor (tableName); for (String col: cols) {HColumnDescriptor hColumnDescriptor = new HColumnDescriptor (col); hTableDescriptor.addFamily (hColumnDescriptor);} try {admin.createTable (hTableDescriptor);} catch (IOException e) {e.printStackTrace () } the above is all the contents of this article "how to use HBase JAVA API". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!