Need help to connect to local DB from Data bricks

Skesaram
New Contributor II

jdbcHostname="478"

jdbcPort=1433

jdbcDatabase="Onprem_AzureDB"

jdbcUsername="upendra"

jdbcPassword="upendrakumar"

jdbcDriver="com.microsoft.sqlserver.jdbc.SQLServerDriver"

jdbcUrl=f"jdbc:sqlserver://{jdbcHostname}:{jdbcPort};databaseName={jdbcDatabase};user={jdbcUsername};password={jdbcPassword}"

test1=spark.read.format("jdbc").option("url",jdbcUrl).option("dbtable","onprem_table1").load()

display(test1)

Error:

com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host 478, port 1433 has failed. Error: "478. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".

Debayan
Databricks Employee
Databricks Employee

Hi, Could you please verify the network connectivity from Databricks to the SQL server? Please make sure SQL:port is allowed in your firewall rules or security groups.