<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Read HBase Table by using Spark/Scala in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Read-HBase-Table-by-using-Spark-Scala/m-p/164299#M126669</link>
    <description>&lt;P&gt;Hi, this is my Scala code to read Hbase tables. It's working with Hbase latest version 1.1.2.2.6.4.0-91 (HDP 2.6.4, Ambari 2.6.1).&lt;/P&gt;&lt;P&gt;The key parameter is:&lt;/P&gt;&lt;PRE&gt;conf.set("zookeeper.znode.parent", "/hbase-unsecure")&lt;/PRE&gt;&lt;P&gt;because zookeeper doesn't hold the Hbase master detail.&lt;/P&gt;&lt;P&gt;Check:&lt;/P&gt;&lt;P&gt;# /usr/hdp/2.6.4.0-91/zookeeper/bin/zkCli.sh -server &amp;lt;server&amp;gt;.hortonworks.com:2181&lt;/P&gt;&lt;P&gt;# ls /hbase-unsecure/master return []&lt;/P&gt;&lt;PRE&gt;import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.hbase.HBaseConfiguration
import org.apache.hadoop.hbase.client.Connection
import org.apache.hadoop.hbase.client.ConnectionFactory
import org.apache.hadoop.hbase.TableName

object Hbase {
  val conf: Configuration = HBaseConfiguration.create()
  def main(args: Array[String]): Unit = {


    //conf.set("hbase.master", "&amp;lt;server&amp;gt;.hortonworks.com" + ":" + "60000")
    conf.setInt("timeout", 120000)
    conf.set("hbase.zookeeper.quorum", "&amp;lt;server&amp;gt;.hortonworks.com")
    conf.set("zookeeper.znode.parent", "/hbase-unsecure") // IMPORTANT!!!
    conf.setInt("hbase.client.scanner.caching", 10000)
    val connection: Connection = ConnectionFactory.createConnection(conf)
    val table = connection.getTable(TableName.valueOf("trading"))
    print("connection created")
    val admin = connection.getAdmin
    // List the tables.
    val listtables = admin.listTables()
    listtables.foreach(println)
    connection.close()
  }
}&lt;/PRE&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;'trading', {NAME =&amp;gt; 'ca', BLOOMFILTER =&amp;gt; 'ROW', VERSIONS =&amp;gt; '1', IN_MEMORY =&amp;gt; 'false', KEEP_DELETED_CELLS =&amp;gt; 'FALSE', DATA_BLOCK_ENCODING =&amp;gt; 'NONE', TTL =&amp;gt; 'FOREVER', COMPRESSION =&amp;gt; 'NONE', MIN_VERSIONS =&amp;gt; '0', BLOCKCACHE =&amp;gt; 'true', BLOCKSIZE =&amp;gt; '65536', REPLICATION_SCOPE =&amp;gt; '0'}&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2018 06:46:15 GMT</pubDate>
    <dc:creator>YOTTALABS</dc:creator>
    <dc:date>2018-02-02T06:46:15Z</dc:date>
  </channel>
</rss>

