title: how to set up hive database connection inside spark
body: <p>New to spark and hive. Currently I can run spark 1.5.2 and I also have access to hive from the command line. I want to be able to programmatically connect to the hive database, run a query and extract the data to a dataframe, all inside spark. I imagine this sort of workflow is pretty standard. But I have no idea how to do it. </p>
  
  <p>Right now I know I can get a HiveContext in spark:</p>
  
  <pre><code>import org.apache.spark.sql.hive.HiveContext;
  </code></pre>
  
  <p>I can do all my querying inside hive like </p>
  
  <pre><code>SHOW TABLES; 
  &gt;&gt;customers
    students
    ...
  </code></pre>
  
  <p>Then  I can get data from the tables:</p>
  
  <pre><code>SELECT * FROM customers limit 100;
  </code></pre>
  
  <p>How do I string these 2 together inside spark?</p>
  
  <p>Thanks. </p>