I use
- JTDS version: jtds-1.3.1
- MS SQL JDBC version: mssql-jdbc-8.4.0.jre8 even mssql-jdbc-9.2.0.jre8
- Java 8 Update 251
For simplicity, the code will the same as:
Android studio can't connect to database in Azure sql server
I have a problem to connect to SQL Server or Azure SQL.
I want to connect with this syntax:
val connectionString = "jdbc:jtds:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
With this JTDS connection string, I can connect to my SQL Server DB on localhost, but with MS-JDBC, I failed to connect.
val connectionString = "jdbc:sqlserver://192.168.xx.xx:1433;databaseName=myData;user=x1;password=p1;encrypt=true;trustServerCertificate=true;"
I get the following errors:
com.microsoft.sqlserver.jdbc.SQLServerException: The Driver could not establish a secured connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "Socket is closed". ClientConnectionId: xxxxxxxxxxxxxxxxx
An interesting thing happens when I connect with JTDS version to SQL Azure with the command:
jdbc:jtds:sqlserver://xxxxx.database.windows.net:1433;database=xxxxx;user=username;password=password;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
I failed to connect to SQL Azure with the following errors
java.sql.SQLException: Reason: Login Failed due to client TLS Version being less than minimal TLS Version allowed by the server
I already tried:
- SSLProtocol=TLSv1.2 (TLS, TLSv1.0, TLSv1.1) => none work
- ssl=require
Is it a bug with JTDS, a bug with JDBC, o isr my connection string invalid? I can connect to SQL Azure with my dotnet apps (C#).