AnsweredAssumed Answered

Unable to connect to maprdb table through java api

Question asked by SanjeevSukumaran on Jun 22, 2016
Latest reply on Jun 22, 2016 by aaron


Hello,

 

I am trying to access a mapr table using java client api.Below is the code.

 

package hbase;

 

 

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.hbase.client.HTable;

 

 

 

 

import org.apache.hadoop.hbase.client.Result;

import org.apache.hadoop.hbase.client.ResultScanner;

import org.apache.hadoop.hbase.client.Scan;

 

 

 

 

public class GettingStarted

{

  public static void main(String[] args) throws IOException

  {

 

   Configuration hconfig=HBaseConfiguration.create();

 

 

   hconfig.addResource(new Path("/opt/mapr/hbase/hbase-0.98.12/conf/hbase-site.xml"));

   hconfig.set("hbase.zookeeper.quorum","localhost");

   hconfig.set("hbase.zookeeper.property.clientPort","5181");

   HTable table = new HTable(hconfig, "/opt/mapr/env/user/demo");

 

 

   Scan scan = new Scan();

   ResultScanner scanner = table.getScanner(scan);

 

   for (Result result = scanner.next(); result != null; result = scanner.next())

 

 

       System.out.println("Found row : " + result);

       //closing the scanner

       scanner.close();

 

 

  }

}

 

But i am unable to connect.

Is it compulsory to install mapr client to connect with remote hbase??

 

Kindly help me with the same.

 

Thanks and Regards

Sanjeev Sukumaran

Outcomes