---
title: "How to read data from Hbase?"  
description: "How to read data from Hbase?"  
author: "Anonymous User"  
published: 2015-12-03  
updated: 2015-12-04  
canonical: https://www.mindstick.com/forum/33679/how-to-read-data-from-hbase  
category: "java"  
tags: ["database", "java"]  
reading_time: 2 minutes  

---

# How to read data from Hbase?

I'm use to [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database), but I need to read [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science) from a [HBase](https://www.mindstick.com/articles/12055/big-data-evolution-of-hbase) table. Any help on this would be great. A book or maybe just some [sample](https://www.mindstick.com/news/2174/mars-mission-by-nasa-prepares-for-tests) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) to read from the table. Someone said using a [scanner](https://www.mindstick.com/forum/33502/java-scanner-issue-why-input-is-skipped-when-using-next-nextint-etc-after-nextline) would do the trick, but I do not know how to use it

## Replies

### Reply by Anonymous User

From the website:\

```
// Sometimes, you won't know the row you're looking for. In this case, you// use a Scanner. This will give you cursor-like interface to the contents// of the table.  To set up a Scanner, do like you did above making a Put// and a Get, create a Scan.  Adorn it with column names, etc.Scan s = new Scan();s.addColumn(Bytes.toBytes("myLittleFamily"), Bytes.toBytes("someQualifier"));ResultScanner scanner = table.getScanner(s);try {  // Scanners return Result instances.  // Now, for the actual iteration. One way is to use a while loop like so:  for (Result rr = scanner.next(); rr != null; rr = scanner.next()) {    // print out the row we found and the columns we were looking for    System.out.println("Found row: " + rr);  }  // The other approach is to use a foreach loop. Scanners are iterable!  // for (Result rr : scanner) {  //   System.out.println("Found row: " + rr);  // }} finally {  // Make sure you close your scanners when you are done!  // Thats why we have it inside a try/finally clause  scanner.close();}
```


---

Original Source: https://www.mindstick.com/forum/33679/how-to-read-data-from-hbase

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
