- 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()]); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。