Answer the question
In order to leave comments, you need to log in
How to connect to MS SQL Server from apache spark in java?
Hello!
Tell me, please, what is the problem?
There is a java code that creates a session for spark, configures it and tries to access MS SQL Server database from spark:
SparkConf conf = new SparkConf().setMaster("local[4]").setAppName("Word Count");
conf.set("spark.driver.extraClassPath","C:\\temp\\sqljdbc42.jar");//this path contains the driver
conf.set("spark.executor.extraClassPath","C:\\ temp\\sqljdbc42.jar");
String url = "jdbc:sqlserver://10.11.0.2\\sql2012;database=xyz;user=test;password=test";
Properties p =new Properties();
Dataset df2 = spark.read().jdbc(url,"abtests",p);
df2.show();
As a result of execution, an error appears:
"Exception in thread "main" java.sql.SQLException: No suitable driver"
the code is executed on Windows 10 x64, spark was not specifically installed, the code accesses the "local" spark, which is a member of the operation, such as reading files and building a DataFrame' ov is successfully executed.
I'm probably doing something wrong:
- I put the driver in the wrong place
- the driver turned out to be the
wrong one - I configured the spark session incorrectly
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question