6.5 向表中插入数据

/**
 * 向表中插入数据
 *
 * @param tableName
 * @param rowKey
 * @param cf
 * @param column
 * @param value
 * @throws IOException
 */
private static void addData(String tableName, String rowKey, String cf, String column, String value) throws IOException {
    Table table = conn.getTable(TableName.valueOf(tableName));

    Put put = new Put(Bytes.toBytes(rowKey));
    put.addColumn(Bytes.toBytes(cf), Bytes.toBytes(column), Bytes.toBytes(value));
    table.put(put);
    table.close();
}
Copyright © 尚硅谷大数据 2019 all right reserved,powered by Gitbook
该文件最后修订时间: 2019-03-26 08:52:09

results matching ""

    No results matching ""