I'm trying to use Spark via Python to access (via JDBC) a PostGres database and a MSSQL database in the same session. In the spark-defaults.conf file I can get one or the other to work but not both.
These two work independently:
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/postgresql-9.4.1208.jre6.jar
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/sqljdbc4.jar
I tried these three and neither works (I get the "no suitable driver" error):
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/postgresql-9.4.1208.jre6.jar sqljdbc4.jar
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/postgresql-9.4.1208.jre6.jar /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/sqljdbc4.jar
Thanks in advance.
If you want to use multiple jars you need to chain them together. If you're running Linux, the chain operator is :
, on Windows its ;
.
For example, on Linux your extraClassPath
would be:
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/postgresql-9.4.1208.jre6.jar:/Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/sqljdbc4.jar
On Windows:
spark.driver.extraClassPath /Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/postgresql-9.4.1208.jre6.jar;/Users/myusername/spark-1.6.1-bin-hadoop2.4/lib/sqljdbc4.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With