Hello,
It looks issue with JDBC URL. When I am trying to access the Azure SQL database. I was facing the same issue. So I have created JDBC URL as below and it went well.
jdbc:sqlserver://<serverurl>:1433;database=<databasename>;user=<username>@<servername>;password=<password>;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
db_user = "XXXXXXX"
db_password = "XXXXXXX"
db_jdbc_url = "jdbc:sqlserver://<serverurl>:1433;database=<databasename>;user=<db_user>@<servername>;password=<db_password>;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;"
def datahub_db_config(query):
queryresult = (spark.read.format("jdbc")
.option("url", db_jdbc_url)
.option("query", query).
option("user", db_user)
.option("password",db_password).load()
)
return queryresult
result = datahub_db_config(query="select * from <tablename>")
result = datahub_db_config(query=query)
โEmpower Minds, Share Wisdom - Together We Grow!โ