[ 
https://issues.apache.org/jira/browse/SPARK-12563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15084963#comment-15084963
 ] 

Sonya Huang commented on SPARK-12563:
-------------------------------------

Thanks [~jayadevan.m]. It looks like right after you posted this, someone made 
a commit to fix another issue (SPARK-12579) which might make this obsolete.

I also realized that DataFrameWriter.jdbc actually calls JdbcUtils.saveTable so 
it isn't a redundant function as I thought when I first encountered this.

> "No suitable driver" when calling JdbcUtils.saveTable in isolation
> ------------------------------------------------------------------
>
>                 Key: SPARK-12563
>                 URL: https://issues.apache.org/jira/browse/SPARK-12563
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.5.2
>            Reporter: Sonya Huang
>            Priority: Minor
>
> When calling the following function
> JdbcUtils.saveTable(df, url, table, properties)
> the following exception is thrown.
> Exception in thread "main" java.sql.SQLException: No suitable driver
>         at java.sql.DriverManager.getDriver(DriverManager.java:315)
>         at 
> org.apache.spark.sql.execution.datasources.jdbc.DriverRegistry$.getDriverClassName(DriverRegistry.scala:55)
>         at 
> org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.saveTable(JdbcUtils.scala:212)
>         at com.pul.sive.TestThingy$$anonfun$main$2.apply(TestThingy.scala:77)
>         at com.pul.sive.TestThingy$$anonfun$main$2.apply(TestThingy.scala:69)
>         at 
> scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
>         at 
> scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:98)
>         at 
> scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:226)
>         at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:39)
>         at scala.collection.mutable.HashMap.foreach(HashMap.scala:98)
>         at com.pul.sive.TestThingy$.main(TestThingy.scala:69)
>         at com.pul.sive.TestThingy.main(TestThingy.scala)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:497)
>         at 
> org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:674)
>         at 
> org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:180)
>         at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:205)
>         at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:120)
>         at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
> However, the above works if the following is called directly before:
> JdbcUtils.createConnection(url, properties)
> It appears that JdbcUtils.saveTable attempts to get the driver from 
> DriverRegistry before reading the contents of the properties argument. 
> Jdbc.createConnection adds the driver to DriverRegistry as a side effect, so 
> this lookup works.
> However it also appears that DataFrame.write.jdbc(url, table, properties) 
> accomplishes the same thing with more flexibility, so I am not sure if 
> JdbcUtils.saveTable is redundant.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to