java 连接不上hbase,无法使用Java连接到Hbase

Hi i have installed ubuntu on my machine and installed hbase0.98-hadoop2. Then i edited hbase-env.sh file and hbase-site.xml. Now my hbase shell is working fine. But when i try to connect to hbase from Java code using hbase java api's. I get errors.

My Code is:

Configuration hc = HBaseConfiguration.create();

HTableDescriptor ht = new HTableDescriptor("User");

ht.addFamily( new HColumnDescriptor("Id"));

ht.addFamily( new HColumnDescriptor("Name"));

System.out.println( "connecting" );

HBaseAdmin hba = new HBaseAdmin( hc );

System.out.println( "Master running ? "+ hba.isMasterRunning());

System.out.println( "Creating Table" );

hba.createTable( ht );

System.out.println("Done......");

My output is:

connecting

Exception in thread "main" java.lang.NumberFormatException: For input string: "42529`;��7ec�PBUF

jamil-37037�������)

at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)

at java.lang.Integer.parseInt(Integer.java:492)

at java.lang.Integer.parseInt(Integer.java:527)

at org.apache.hadoop.hbase.HServerAddress.(HServerAddress.java:63)

at org.apache.hadoop.hbase.MasterAddressTracker.getMasterAddress(MasterAddressTracker.java:63)

at org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getMaster(HConnectionManager.java:353)

at org.apache.hadoop.hbase.client.HBaseAdmin.(HBaseAdmin.java:89)

at HBaseConnector.main(HBaseConnector.java:157)

My Code is creating problem at HbaseAdmin. Any help please?

Remember i installed standalone hbase and did not installed hadoop separately. It was the same package hbase0.98.6-hadoop2.

解决方案

If you are using maven, please see if you are using the exact versioned dependencies as your hbase setup is. Foexample, if your hbase is suppose hbase-0.x.x you must add the dependency hbase-0.x.x in your project. Similarly check all other dependencies like hadoop, zookeeper as well. If not maven then download the proper jars and add them to your classpath. If you are unaware, go to the lib folder of your application and see the jars.

Hope this helps. Thanks

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值