connect to mysql from spark
<p>I am trying to follow the instructions mentioned here...</p>

<p><a href="https://www.percona.com/blog/2016/08/17/apache-spark-makes-slow-mysql-queries-10x-faster/" rel="nofollow">https://www.percona.com/blog/2016/08/17/apache-spark-makes-slow-mysql-queries-10x-faster/</a></p>

<p>and here...</p>

<p><a href="https://www.percona.com/blog/2015/10/07/using-apache-spark-mysql-data-analysis/" rel="nofollow">https://www.percona.com/blog/2015/10/07/using-apache-spark-mysql-data-analysis/</a></p>

<hr>

<p>I am using sparkdocker image.</p>

<pre><code>docker run -it -p 8088:8088 -p 8042:8042 -p 4040:4040 -h sandbox sequenceiq/spark:1.6.0 bash

cd /usr/local/spark/

./sbin/start-master.sh

./bin/spark-shell --driver-memory 1G --executor-memory 1g --executor-cores 1 --master local
</code></pre>

<p>This works as expected:</p>

<pre><code>scala&gt; sc.parallelize(1 to 1000).count()
</code></pre>

<p>But this shows an error:</p>

<pre><code>val jdbcDF = spark.read.format("jdbc").options(
  Map("url" -&gt;  "jdbc:mysql://1.2.3.4:3306/test?user=dba&amp;password=dba123",
  "dbtable" -&gt; "ontime.ontime_part",
  "fetchSize" -&gt; "10000",
  "partitionColumn" -&gt; "yeard", "lowerBound" -&gt; "1988", "upperBound" -&gt; "2016", "numPartitions" -&gt; "28"
  )).load()
</code></pre>

<p>And here is the error:</p>

<pre><code>&lt;console&gt;:25: error: not found: value spark
         val jdbcDF = spark.read.format("jdbc").options(
</code></pre>

<p>How do I connect to MySQL from within spark shell?</p>