title: java.sql.SQLException: No suitable driver found when loading DataFrame into Spark SQL
body: <p>I'm hitting very strange problem when trying to load JDBC DataFrame into Spark SQL. </p>
  
  <p>I've tried several Spark clusters - YARN, standalone cluster and pseudo distributed mode on my laptop. It's reproducible on both Spark 1.3.0 and 1.3.1. The problem occurs in both <code>spark-shell</code> and when executing the code with <code>spark-submit</code>. I've tried MySQL &amp; MS SQL JDBC drivers without success.</p>
  
  <p>Consider following sample:</p>
  
  <pre class="lang-scala prettyprint-override"><code>val driver = "com.mysql.jdbc.Driver"
  val url = "jdbc:mysql://localhost:3306/test"
  
  val t1 = {
    sqlContext.load("jdbc", Map(
      "url" -&gt; url,
      "driver" -&gt; driver,
      "dbtable" -&gt; "t1",
      "partitionColumn" -&gt; "id",
      "lowerBound" -&gt; "0",
      "upperBound" -&gt; "100",
      "numPartitions" -&gt; "50"
    ))
  }
  </code></pre>
  
  <p>So far so good, the schema gets resolved properly:</p>
  
  <pre><code>t1: org.apache.spark.sql.DataFrame = [id: int, name: string]
  </code></pre>
  
  <p>But when I evaluate DataFrame: </p>
  
  <pre><code>t1.take(1)
  </code></pre>
  
  <p>Following exception occurs:</p>
  
  <pre><code>15/04/29 01:56:44 WARN TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, 192.168.1.42): java.sql.SQLException: No suitable driver found for jdbc:mysql://&lt;hostname&gt;:3306/test
      at java.sql.DriverManager.getConnection(DriverManager.java:689)
      at java.sql.DriverManager.getConnection(DriverManager.java:270)
      at org.apache.spark.sql.jdbc.JDBCRDD$$anonfun$getConnector$1.apply(JDBCRDD.scala:158)
      at org.apache.spark.sql.jdbc.JDBCRDD$$anonfun$getConnector$1.apply(JDBCRDD.scala:150)
      at org.apache.spark.sql.jdbc.JDBCRDD$$anon$1.&lt;init&gt;(JDBCRDD.scala:317)
      at org.apache.spark.sql.jdbc.JDBCRDD.compute(JDBCRDD.scala:309)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
      at org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:35)
      at org.apache.spark.rdd.RDD.computeOrReadCheckpoint(RDD.scala:277)
      at org.apache.spark.rdd.RDD.iterator(RDD.scala:244)
      at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:61)
      at org.apache.spark.scheduler.Task.run(Task.scala:64)
      at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:203)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>When I try to open JDBC connection on executor:</p>
  
  <pre class="lang-scala prettyprint-override"><code>import java.sql.DriverManager
  
  sc.parallelize(0 until 2, 2).map { i =&gt;
    Class.forName(driver)
    val conn = DriverManager.getConnection(url)
    conn.close()
    i
  }.collect()
  </code></pre>
  
  <p>it works perfectly:</p>
  
  <pre><code>res1: Array[Int] = Array(0, 1)
  </code></pre>
  
  <p>When I run the same code on local Spark, it works perfectly too:</p>
  
  <pre><code>scala&gt; t1.take(1)
  ...
  res0: Array[org.apache.spark.sql.Row] = Array([1,one])
  </code></pre>
  
  <p>I'm using Spark pre-built with Hadoop 2.4 support.</p>
  
  <p>The easiest way to reproduce the problem is to start Spark in pseudo distributed mode with <code>start-all.sh</code> script and run following command:</p>
  
  <pre><code>/path/to/spark-shell --master spark://&lt;hostname&gt;:7077 --jars /path/to/mysql-connector-java-5.1.35.jar --driver-class-path /path/to/mysql-connector-java-5.1.35.jar
  </code></pre>
  
  <p>Is there a way to work this around? It looks like a severe problem, so it's strange that googling doesn't help here.</p>