Basically I'm trying to connect to a SQL Server database on my local machine from databricks using a JDBC connection. I'm following the procedure mentioned in the documentation as shown here on the databricks website.
I used the following code as mentioned on the website:
jdbcHostname = "localhost"
jdbcDatabase = "TestDB"
jdbcPort = "3306"
jdbcUrl = "jdbc:mysql://{0}:{1}/{2}".format(jdbcHostname, jdbcPort, jdbcDatabase)
connectionProperties = {
"jdbcUsername" : "user1",
"jdbcPassword" : "pass1",
"driver" : "com.microsoft.sqlserver.jdbc.SQLServerDriver"
}
pushdown_query = "SELECT * FROM dbo.customer"
df = spark.read.jdbc(url=jdbcUrl, table=pushdown_query,properties=connectionProperties)
display(df)
But I'm getting this error
IllegalArgumentException: requirement failed: The driver could not open a JDBC connection. Check the URL: jdbc:mysql://localhost:3306/TestDB
Can anyone explain why is it happening? How can I fix this error?