Scan(Read) a Hbase Table data using Java

Category : Hadoop | Sub Category : Apache HBase | By Runner Dev Last updated: 2020-10-17 21:17:29 Viewed : 167

Scan(Read) a Hbase Table  data using Java

1.        Create a maven project

Dependency : add the below dependency in pom.xml


  <!-- -->






  2.       Scan a Hbase Table  :

Table Name:
 package com.runnerdev;




import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.hbase.HBaseConfiguration;

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

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

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

import org.apache.hadoop.hbase.util.Bytes;

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



 * Delete data from Hbase in java *



public class ReadHBaseData {


          static String hbase_host = "";

          static String hbase_Port = "2191";


          public static void main(String[] args) {

                    try {

                              Configuration conf = HBaseConfiguration.create();

                              conf.set("hbase.zookeeper.quorum", hbase_host);

                              conf.set("hbase.zookeeper.clientPort", hbase_Port);

                              System.out.println("Conf::" + conf);

                              HTable hTable = new HTable(conf, "Employee");// Instantiating HTable class

//                           Put p = new Put(Bytes.toBytes("9"));                      

                              Scan scan = new Scan();// Instantiating the Scan class

                              scan.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("name"));// Scan the required columns

                              scan.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("location"));

                              ResultScanner scanner = hTable.getScanner(scan);// Getting the scan result

                              // Reading values from scan result

                              for (Result result =; result != null; result =

                                        System.out.println("Reuslt data : " + result);

                              scanner.close();// closing the scanner


                    } catch (IOException e) {







 Run above program as follows:

Related Articles

Leave a Comment:
at 2022-03-24 18:53:53
The USPSTF recommends screening all adults for depression and providing appropriate treatment and followup. Leqliu [url=]tadalafil cialis[/url] The medicine person might waft or blow smoke at recipients as part of the healing ritual. Xvamzt <a href=>Cialis</a> Rx Mex Pharmacy Siyqip Buy Amoxicillin Antibodics Online Canada - Cialis
at 2022-03-25 18:49:50
achat cialis generique en france [url=]buy cialis generic online cheap[/url] Yrscha narrowing of the pyloric sphincter <a href=>Cialis</a> Vdfsba - cialis online Kukkqu Achat Cialis 20mg Original