Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use HBase JAVA API

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report