hadoop - Hbase Java API Example -
i new hbase development. following link. using hbase-1.1.2 release. when use sample code getting warnings. there several methods got deprecated (example, new hbaseadmin(conf);) saw hbaseadmin class has 3 constructors. out of 3 constructors 2 got deprecated. 1 constructor accepts "clusterconnection" argument. don't know following proper link play hbase. can please provide sample example using latest hbase libraries.? running hbase standalone mode.
this should help
hconnection connection; htableinterface htableinterface = null; configuration hbaseconfig = hbaseconfiguration.create(); hbaseconfig.setint("timeout", 120000); //zookeeper quorum, basic info needed 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(); } { htableinterface.close(); connection.close(); }
Comments
Post a Comment