运用Java的API存储汉字到hbase中,代码如下:
public static void insterRow(String tableName,String rowkey,String colFamily,String col,String val) throws IOException {
init();
Table table = connection.getTable(TableName.valueOf(tableName));
Put put = new Put(Bytes.toBytes(rowkey));
put.addColumn(Bytes.toBytes(colFamily), Bytes.toBytes(col), Bytes.toBytes(val));
table.put(put);
//批量插入
/* List putList = new ArrayList();
puts.add(put);
table.put(putList);*/
table.close();
close();
}
参数直接穿得就是"参数"这种格式的
然后从Hbase中读取数据代码如下:
Table table = connection.getTable(TableName.valueOf(tableName));
Get get = new Get(Bytes.toBytes(rowkey));
get.addFamily(Bytes.toBytes(colFamily));
get.addColumn(Bytes.toBytes(colFamily),Bytes.toBytes(col));
Result result