9月15日

今天继续学习hbase

 向表中插入数据

public static void addRowData(String tableName, String rowKey, String columnFamily, String column, String value) throws IOException{

//创建 HTable 对象

HTable hTable = new HTable(conf, tableName);

//向表中插入数据

Put put = new Put(Bytes.toBytes(rowKey));

//向 Put 对象中组装数据

put.add(Bytes.toBytes(columnFamily), Bytes.toBytes(column), Bytes.toBytes(value));

hTable.put(put);

hTable.close();

System.out.println("插入数据成功"); }

通过put来组装数据。

 跟着视频教学敲了一遍。

原文地址:https://www.cnblogs.com/buyaoya-pingdao/p/14901221.html