Forum Discussion
jdbc connector receives TCP/IP error against the warehouse
the data warehouse was created from
https://app.fabric.microsoft.com/groups/me/quickcreate?experience=power-bi
and selecting sample data, so it should be the most standart and avaiable item
I'm not under any firewall, so the allow list isn't related, as far as I see the block is coming from fabric site
I'm facing the same issue from Synapse Spark. The problem is due to Fabric's forced usage of Redirect connections for Azure hosted compute. Local Spark works fine, cloud does not.
The error:
2024-09-07 22:59:22,622 INFO ApplicationMaster [shutdown-hook-0]: Unregistering ApplicationMaster with FAILED (diag message: User class threw exception: com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host ....pbidedicated.windows.net\...dw (redirected from ...-....msit-datawarehouse.fabric.microsoft.com), port 1433 has failed. Error: "null. 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.".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
at com.microsoft.sqlserver.jdbc.SQLServerException.ConvertConnectExceptionToSQLServerException(SQLServerException.java:285)
at com.microsoft.sqlserver.jdbc.SocketFinder.findSocket(IOBuffer.java:2462)
at com.microsoft.sqlserver.jdbc.TDSChannel.open(IOBuffer.java:668)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2695)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2362)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:2213)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1276)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:861)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:677)
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)The code (scala):
val server = driverOpts.FabricSqlKeepAliveDriver.Source.SqlServer.Server
val domain = driverOpts.FabricSqlKeepAliveDriver.Source.SqlServer.Domain
val port = driverOpts.FabricSqlKeepAliveDriver.Source.SqlServer.Port
val database = driverOpts.FabricSqlKeepAliveDriver.Source.SqlServer.Database
val tables = driverOpts.FabricSqlKeepAliveDriver.Source.SqlServer.Tables
val jdbcUrl = s"jdbc:sqlserver://${server}.${domain}:${port};database=${database}"
val connectionProperties = new java.util.Properties()
connectionProperties.setProperty("accessToken", accessToken)
connectionProperties.setProperty("encrypt", "true")
connectionProperties.setProperty("trustServerCertificate", "false")
connectionProperties.setProperty("hostNameInCertificate", s"*.${domain}")
connectionProperties.setProperty("loginTimeout", "30")
DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver());
// This will throw in Azure Synapse Spark
val connection: Connection = DriverManager.getConnection(jdbcUrl, connectionProperties)
Local:
Azure:
In regular Azure SQL, you can force Proxy connections to solve this problem:
Azure SQL Database connectivity architecture - Azure SQL Database and Azure Synapse Analytics | Microsoft Learn
Fabric doesn't have a solution yet, unless someone can comment on this thread.
- benor14702 years agoFrequent Visitor
should I open a feature request or a bug somewhere? currently is shows in the docs like jdbc is a available
https://learn.microsoft.com/en-us/fabric/data-warehouse/connectivity#connect-using-jdbc- mdrakiburrahman2 years ago
Microsoft Employee
I'd open a support ticket and ask the support engineer to raise an "ICM" so he/she can get in touch with the Fabric Software Engineer that wrote this, my guess is, that Software Engineer didn't test in Azure Synapse or other Azure Compute.
- mdrakiburrahman2 years ago
Microsoft Employee
benor1470 I was able to solve the problem.
Old JDBC drivers don't work with Fabric because the Fabric Proxy forces Redirect mode, you need to use the latest JDC drivers wherever you are running your code.
In case of Synapse, even though I was using the latest Driver, Synapse CLASSPATH overrides what the user passes in their JAR. Shading your JAR solves the problem and it works.
Please use this version:
Shade your spark-submit JAR:
Works fine in Synapse: