title: I can't write a Spark DataFrame to database with jdbc
body: <p>i am attempting to write a simple dataframe into oracle database but I get an error message. I use a case class and a list to construct my dataframe. I found that that we can use a method jdbc after a write to insert data to my oracle database. 
  I tried this code:</p>
  
  <pre><code>case class MyClass(A: String, B: Int)
  val MyClass_List = List(MyClass("att1", 1), MyClass("att2", 2))
  
  val MyClass_df = MyClass_List.toDF()
  
  MyClass_df.write
              .mode("append")
              .jdbc(url, tableTest, prop)
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>17/07/12 14:57:04 ERROR JobScheduler: Error running job streaming job 1499864218000 ms.0
  java.lang.NullPointerException
          at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:93)
          at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:426)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:215)
          at org.apache.spark.sql.DataFrameWriter.jdbc(DataFrameWriter.scala:446)
          at Test$$anonfun$1.apply(Test.scala:177)
          at Test$$anonfun$1.apply(Test.scala:117)
          at org.apache.spark.streaming.dstream.DStream$$anonfun$foreachRDD$1$$anonfun$apply$mcV$sp$3.apply(DStream.scala:627)
          at org.apache.spark.streaming.dstream.DStream$$anonfun$foreachRDD$1$$anonfun$apply$mcV$sp$3.apply(DStream.scala:627)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.DStream.createRDDWithLocalProperties(DStream.scala:415)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply$mcV$sp(ForEachDStream.scala:50)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
          at scala.util.Try$.apply(Try.scala:192)
          at org.apache.spark.streaming.scheduler.Job.run(Job.scala:39)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply$mcV$sp(JobScheduler.scala:254)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:254)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:254)
          at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler.run(JobScheduler.scala:253)
          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:748)
  Exception in thread "main" java.lang.NullPointerException
          at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:93)
          at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:426)
          at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:215)
          at org.apache.spark.sql.DataFrameWriter.jdbc(DataFrameWriter.scala:446)
          at Test$$anonfun$1.apply(Test.scala:177)
          at Test$$anonfun$1.apply(Test.scala:117)
          at org.apache.spark.streaming.dstream.DStream$$anonfun$foreachRDD$1$$anonfun$apply$mcV$sp$3.apply(DStream.scala:627)
          at org.apache.spark.streaming.dstream.DStream$$anonfun$foreachRDD$1$$anonfun$apply$mcV$sp$3.apply(DStream.scala:627)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1$$anonfun$apply$mcV$sp$1.apply(ForEachDStream.scala:51)
          at org.apache.spark.streaming.dstream.DStream.createRDDWithLocalProperties(DStream.scala:415)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply$mcV$sp(ForEachDStream.scala:50)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
          at org.apache.spark.streaming.dstream.ForEachDStream$$anonfun$1.apply(ForEachDStream.scala:50)
          at scala.util.Try$.apply(Try.scala:192)
          at org.apache.spark.streaming.scheduler.Job.run(Job.scala:39)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply$mcV$sp(JobScheduler.scala:254)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:254)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler$$anonfun$run$1.apply(JobScheduler.scala:254)
          at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
          at org.apache.spark.streaming.scheduler.JobScheduler$JobHandler.run(JobScheduler.scala:253)
          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:748)
  </code></pre>
  
  <p>i use spark version 2.1.0 and my database as two column A and B respectively typed as varchar and number.</p>
  
  <p>Do you have any Idea?</p>