本地环境
hbase + hdfs 伪分布式模式
java 代码
创建了和HBASE的连接后,将所有表的名称打印到终端输出。
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
public class Demo {
Configuration conf;
Connection connection;
public void buildConnection() {
conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quoram", "localhost");
conf.set("hbase.zookeeper.property.clientPort", "2181");
try {
connection = ConnectionFactory.createConnection(conf);
Admin admin = connection.getAdmin();
TableName[] names = admin.listTableNames();
for (TableName tn : names)
System.out.println("table name:" + tn.getNameAsString());
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
System.out.println("test");
Demo demo = new Demo()