This is how I have successfully been reading data from an SQL server in Databricks Runtime 10.4, using the legacy JDBC driver:
remote_table = (
spark.read.format("jdbc")
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
.option("url", "jdbc:sqlserver://mydomainname.com;database=Runtime")
.option("dbtable", "Runtime.dbo.History")
.option("user", "myusername")
.option("password", "mypassword")
.load()
)
I want to use the "newer" approach with Runtime 12.2:
remote_table = (spark.read
.format("sqlserver")
.option("host", "mydomainname.com")
.option("user", "myusername")
.option("password", "mypassword")
.option("database", "Runtime")
.option("dbtable", "Runtime.dbo.History")
.load()
)
But an error is returned:
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target". ClientConnectionId:56f3b77d-a90a-4c89-98be-88924f364897
And yes, I am remembering to switch the cluster to one with Runtime 12.2.