Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use HBase JAVA API

Shulou Source: shulou.com Published: 2022-06-01 15:54:07 09月26日 Update

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!

Tags: Content articles code value interests guys partners more knowledge industry information information channels static channels references help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info macOS Xiaomi Linux OPPO Reno