- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-09-2025 06:28 AM
The error you are encountering, "com.microsoft.sqlserver.jdbc.SQLServerException: Connection reset," even after a successful nc (netcat) connection, is a common but nuanced problem when connecting Databricks to an on-premise SQL Server. Although your notebook can ping the server and connect at the TCP/IP level, the JDBC handshake can still be interrupted or reset due to issues at the protocol, authentication, or firewall/proxy layer.
Key Troubleshooting Steps
-
Authentication Issues
-
Ensure that the username and password are valid for SQL Server authentication (not Windows Auth or Active Directory unless explicitly supported and configured).
-
Confirm that SQL Authentication is enabled on the SQL Server.
-
-
JDBC URL and Encryption
-
If encrypt=false was specified but SQL Server enforces SSL or vice versa, this can trigger a reset.
-
Try connecting with
encrypt=true;trustServerCertificate=truein the JDBC string (unless your company policy or server prohibits this). -
Test with and without the encryption parameters, based on what the server expects.
-
-
Firewall and Network Path
-
Even if ping/nc is successful, some firewalls allow TCP handshakes but block or reset application-layer traffic, especially over certain ports or for long-lived connections.
-
Verify with your network team that the SQL Server port (default 1433) allows inbound JDBC traffic from your Databricks IPs for the full session duration.
-
Check for any "stateful inspection" or IDS/IPS devices that could drop or reset connections.
-
-
SQL Server Configuration
-
Make sure TCP/IP is enabled on the SQL Server (SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for [Instance]).
-
Confirm that your SQL Server is bound to the correct IP or 'All IPs', and not 'localhost' only.
-
-
JDBC Driver Version
-
Ensure you are using a compatible and up-to-date Microsoft JDBC driver for SQL Server. Old or mismatched drivers can cause handshake failures.
-
-
Proxy/Gateway Issues
-
If connectivity to on-premise is via VPN, SSH tunnel, or another proxy, check that session timeouts/connection limits are not interfering.
-
Additional Suggestions
-
Use a simple test query (like
SELECT 1) to rule out data or schema-related issues. -
Review SQL Server error logs for any incoming connection failures or network-level rejections.
-
If possible, try the same JDBC connection from a different system on the same network to isolate if the problem is Databricks-specific.
-
If your server enforces SSL and you provide
encrypt=false, or vice versa, a reset is likely. -
Some enterprise networks block dynamic port allocation; ensure the SQL Server is using a static port.
Example JDBC URLs
For non-SSL (if server allows):
jdbc:sqlserver://hostname:1433;database=dbname;encrypt=false;user=user;password=pass
For SSL (try this if non-SSL does not work):
jdbc:sqlserver://hostname:1433;database=dbname;encrypt=true;trustServerCertificate=true;user=user;password=pass
If custom instance (not the default), specify instanceName=....
What to Check Next
-
Confirm the correct SQL authentication and connection parameters.
-
Test with both
encrypt=falseandencrypt=true;trustServerCertificate=true. -
Review SQL Server and network/firewall logs for clues.
-
Ask your network/security team if a proxy, NAT, or VPN is terminating the session unexpectedly.
Most likely, the issue is not basic TCP reachability but protocol-level, authentication, or enforced encryption mismatch. Work with your SQL Server and network teams to ensure all layers are compatible with your Databricks configurationration.