已经创建了一个学生宿舍管理系统
数据表表名:student_info
列族1:students
列族2:dormitorys
列族3:staff_members
将行键为001的dormits列族下的列名为hostel No.的数据更改为115:
package myhbase;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.util.Bytes;
public class UpdateData {
public static void main(String[] args) throws IOException{
updatedata("student_info");
}
public static void updatedata(String tableName) throws IOException{
Configuration conf = HBaseConfiguration.create();
HTable hTable = new HTable(conf,"student_info");
org.apache.hadoop.hbase.client.Put p = new Put(Bytes.toBytes("001"));
//Updating
p.add(Bytes.toBytes("dormitorys"),
Bytes.toBytes("hostel_No."),Bytes.toBytes("115"));
//save
hTable.put(p);
System.out.println("data Updated!");
hTable.close();
}
}