2015-02-10 88 views
0

我在java中使用HBase API,我只是運行一個測試程序來檢索並在HBase表中創建一些記錄。我的HBase在Amazon EC2 linux實例上配置。 我試圖設置動物園管理員的IP和端口,但它給了我在下面.set嘗試遠程訪問HBase時出錯

Configuration conf = new Configuration(); 
conf.set("hbase.zookeeper.quorum", HBaseConf.zookeeperIP); 
conf.set("hbase.zookeeper.property.clientPort", HBaseConf.zookeeperPort); 

它不承認.set方法並給出語法錯誤的錯誤。我導入了所有必需的軟件包,但沒有任何幫助。有人可以告訴我如何解決這個問題。

回答

0

您需要使用HBaseConfiguration對象:

HBaseConfiguration conf = new HBaseConfiguration(); 
+0

同樣的錯誤。請檢查: https://drive.google.com/file/d/0B7Mh8qOofl7QNElVelJKRkxyaEk/view?usp=sharing – Sibtain 2015-02-10 10:52:43

+0

我不知道你的jar版本,但它可能是:'Configuration conf = HBaseConfiguration.create() ;'以及。 – 2015-02-10 10:54:34

+0

這也不適合我。我正在使用hbase-0.94.26.jar。 我應該在我的eclipse項目中包含hbase-site.xml嗎? – Sibtain 2015-02-10 10:59:03

0

你應該使用Hbaseconfiguration.create()

0
private static Configuration conf = null; 
/** 
* Initialization 
*/ 
static { 
    conf = HBaseConfiguration.create(); 
} 

如果不工作,那麼這樣做,

加HBase的/ conf目錄下的類路徑,或者如果您正在使用eclipse/IDE,然後去建立路徑 - >鏈接源並添加hbase/conf目錄

相關問題