欢迎投稿

今日深度:

java客户端通过get方法获取Hbase的数据,gethbase

java客户端通过get方法获取Hbase的数据,gethbase


public static void main(String[] args) throws MasterNotRunningException, IOException{
// TODO Auto-generated method stub
String tableName = "zrl_emp";

Configuration conf = HBaseConfiguration.create();
conf.set("hbase.master", "hdfs://Master.Hadoop:60000");
conf.set("hbase.rootdir", "hdfs://Master.Hadoop:9000/hbase");
conf.set("hbase.zookeeper.property.clientPort", "2181");
conf.set("hbase.zookeeper.quorum", "Master.Hadoop,Slave1.Hadoop");

Connection conn = ConnectionFactory.createConnection(conf);
Table table = conn.getTable(TableName.valueOf(tableName));

Get g = new Get(Bytes.toBytes("rowKey1"));
Result result = table.get(g);

byte [] value = result.getValue(Bytes.toBytes("personal data"), Bytes.toBytes("newColumnName2"));
byte[] value1 = result.getValue(Bytes.toBytes("personal data"), Bytes.toBytes("city"));

table.close();
System.out.println(result.toString());
System.out.println(Bytes.toString(value));
System.out.println(Bytes.toString(value1));
}

www.htsjk.Com true http://www.htsjk.com/hbase/28749.html NewsArticle java客户端通过get方法获取Hbase的数据,gethbase public static void main(String[] args) throws MasterNotRunningException, IOException{ // TODO Auto-generated method stub String tableName = "zrl_emp"; Configuration conf = HBaseCon...
相关文章
    暂无相关文章
评论暂时关闭