I am very new to HBase development. I am following link. I am using Hbase-1.1.2 release. When I use the sample code I am getting warnings. There are several methods got deprecated (Example, new HBaseAdmin(conf);) I saw the HBaseAdmin class it has 3 constructors. Out of 3 constructors 2 got deprecated. Only one constructor which accepts "ClusterConnection" as an argument. I don't know I am following the proper link to play with the HBase. Can any please provide a sample example by using the latest hbase libraries.? I am running HBase as a standalone mode.
This should help
HConnection connection;
HTableInterface hTableInterface = null;
Configuration hBaseConfig = HBaseConfiguration.create();
hBaseConfig.setInt("timeout", 120000);
//zookeeper quorum, basic info needed to proceed
hBaseConfig.set("hbase.zookeeper.quorum","host1, host2, host3");
hBaseConfig.set("hbase.zookeeper.property.clientPort", "2181");
hBaseConfig.set("zookeeper.znode.parent", "/hbase-unsecure");
connection = HConnectionManager.createConnection(hBaseConfig);
hTableInterface = connection.getTable(TableName.valueOf("amarTest"));
try {
Put put = new Put(Bytes.toBytes("999"));
put.add(Bytes.toBytes("cf"),Bytes.toBytes("name"), Bytes.toBytes("amar"));
hTableInterface.put(put);
System.out.println("done");
} catch (Exception e) {
e.printStackTrace();
} finally {
hTableInterface.close();
connection.close();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With