zoukankan      html  css  js  c++  java
  • Hbase Java API调用实例

    • pom依赖

      hbase.version使用与Hbase数据库兼容的版本

            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-server</artifactId>
                <version>${hbase.version}</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-common</artifactId>
                <version>${hbase.version}</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.hbase</groupId>
                <artifactId>hbase-client</artifactId>
                <version>${hbase.version}</version>
                <scope>runtime</scope>
            </dependency>    
    • 配置信息
    static Configuration configuration = HBaseConfiguration.create();
    static {
          configuration.set("hbase.zookeeper.quorum", "localhost");
          configuration.set("hbase.zookeeper.property.clientPort", "2181");
    }
    • 查询所有表
    private String[] getHbaseTables(Configuration configuration) {
            ArrayList<String> tables = new ArrayList<>();
            try {
                HBaseAdmin hBaseAdmin = new HBaseAdmin(configuration);
                if (hBaseAdmin != null) {
                    TableName[] tableNames = hBaseAdmin.listTableNames();
                    for (TableName tableName : tableNames) {
                        tables.add(tableName.getNameAsString());
                    }
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            return tables.toArray(new String[tables.size()]);
        }
  • 相关阅读:
    Next Permutation
    SpringMVC配置信息
    Servlet详解(转载)
    Length of Last Word
    Maximum Subarray**
    Divide Two Integers
    Generate Parentheses***
    http解码-2
    编码-1
    扫描工具对比
  • 原文地址:https://www.cnblogs.com/mohanchen/p/10772250.html
Copyright © 2011-2022 走看看