cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Remote SQL Server Instance Connection using JDBC

Upendra_Dwivedi
New Contributor II

Hi All,

I am connecting Remote SQL Server Instance using JDBC Driver, I have enabled TCP/IP and Setup the Firewall Rule. When i am querying the instance i am getting this error:

(com.microsoft.sqlserver.jdbc.SQLServerException) The TCP/IP connection to the host 192.168.x.x, port 1433 has failed. Error: "Connect timed out. 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."

Here is my code:

remote_table = (
    spark.read
    .format("sqlserver")
    .option("host", "192.168.x.x")
    .option("port", "1433")
    .option("user", "xxxx")
    .option("password", "xxxxxxxxx")
    .option("database", "PRACTICE")
    .option("dbtable", "dbo.TblGender")
    .load()
)

remote_table.show()
 
My question is:
1. I am using ipv4 address of my personal computer as host, so is it correct?
2. If i am using the server name as host i am getting the same error.
 
If everything is correct then what could be the problem?
 
Thanks,
Upendra Dwivedi
5 REPLIES 5

Davinder
New Contributor

192.168.x.x is a local ip address, it will not work in databricks notebook. First try to find your public ip address and try to connect through SQL Server management studio or .udl file. If it works, then you can use the same ip in notebook.

I am able to connect using is ip address through another laptop where ssms is installed and i have tested the connection using udl file, i am able to connect. i think this is not the problem.

Yes, that will work because you are on the same local network. To connect from the outside network, you have to use the public ip address. 

turagittech
New Contributor III

If you want to access a local SQL server, you'll need a Private Link to access the server. If it's on your own local machine, that's likely not possible. Creating a VPN to your machine is a unique problem, and you would be better off using a VM or a PAAS SQL database as the source.

Thank You for the reply but the solution should be on-prem ssms or any other rdbms direct connection with azure databricks.

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now