I am unable to connect to a Azure SQL Server instance running in a local Docker container, either via the IntelliJ database tool window or via a Spring Boot App. The connection works as expected with Azure Data Explorer. Here are the configurations and error messages for all three systems and for the SQL server.
Docker
Configuration
services:
azure-db:
image: "mcr.microsoft.com/azure-sql-edge:1.0.6"
container_name: azure-db
hostname: azure-db
environment:
MSSQL_SA_PASSWORD: '********'
ACCEPT_EULA: 'Y'
ports:
- "5700:1433"
volumes:
- "azure-sql-frame-contracts-volume:/var/opt/mssql"
[...]
Spring Boot App ❌
Configuration
spring:
datasource:
username: SA
password: ********
url: jdbc:sqlserver://localhost:5700;encrypt=true;trustServerCertificate=true;database=*****
Error
2024-07-05T09:47:30.157+02:00 INFO 28280 --- [*****] [ main]
com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-07-05T09:48:00.821+02:00 WARN 28280 --- [*****] [ main]
c.m.s.j.internals.SQLServerConnection : ConnectionID:1 ClientConnectionId:
5fd36ce1-4fec-49f0-b5b4-a32f2300516b Prelogin error:
host localhost port 5700 Unexpected response type:72
IntelliJ database tool window ❌
Configuration
with encrypt=true
and trustServerCertificate=true
in the Advanced tab.
Error
Failed
DBMS: Microsoft SQL Server (ver. 15.00.2000)
Case sensitivity: plain=mixed, delimited=mixed
Driver: Microsoft JDBC Driver 12.2 for SQL Server (ver. 12.2.0.0, JDBC4.2)
Effective version: Azure SQL Database (ver. 15.0.2000)
[08S01] Fehler beim Herstellen der TCP/IP-Verbindung mit dem Host 'localhost', Port 5700. Fehler:
'Der Treiber hat eine unerwartete Antwort vor der Anmeldung erhalten. Überprüfen Sie die
Verbindungseigenschaften, und stellen Sie sicher, dass eine SQL Server-Instanz auf dem Host
ausgeführt wird, die TCP/IP-Verbindungen am Port annimmt. Dieser Treiber kann nur mit
SQL Server 2005 oder höher verwendet werden.'. ClientConnectionId:163feed3-d487-4e41-ab56-e835029209df.
Verified DeepL translation
Error establishing the TCP/IP connection with the host ‘localhost’, port 5700. error: ‘The driver received an unexpected response before logging on. Check the connection properties and make sure that a SQL Server instance is running on the host, and that it accepts TCP/IP connections on the port. This driver can only be used with SQL Server 2005 or higher.’. ClientConnectionId:163feed3-d487-4e41-ab56-e835029209df.
Azure Data Explorer ✔️
Configuration
Success
This has worked for me in the past but got more spotty over time, I could usually get it to work with a restart or such, but now it seems completely broken. The same configuration works for my colleagues on MacOS. I have two VPN clients installed, but they are not active.
Test-NetConnection localhost -Port 5700
succeeds with
ComputerName : localhost
RemoteAddress : ::1
RemotePort : 5700
InterfaceAlias : Loopback Pseudo-Interface 1
SourceAddress : ::1
TcpTestSucceeded : True