Getting `TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum` while trying to connect to MS SQL server

Viewed 14319

This is my connection String:

public static void connectToDatabase() {
    String url = "jdbc:sqlserver://192.168.0.95\\instance;databaseName=sampleDB";
          
    String username = "sa";
    String password = "pass";

    try {
       Connection conn =  DriverManager.getConnection(url,username,password);
       System.out.println("Connected to sql server");                   
    }

I have never used MS SQL but i need to connect and this is error that i got:

avg 12, 2020 2:45:47 PM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
WARNING: TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. 
ClientConnectionId:33111bca-b8c7-4be3-9673-b012c5949817

I'm using windows 7 professional(don't ask). How can i fix this?

3 Answers

In a Maven project you can change version in pom.xml like this;

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>8.2.1.jre11</version>
</dependency>

I am getting this issue because my server password is expired

Warning message 'WARNING: TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.' does not have anything to do with the connection exception.

Even with the warning, the connections would be established. The issue in connection seems to be with the connection parameters.

Instead of String url = "jdbc:sqlserver://192.168.0.95\instance;databaseName=sampleDB";

use String url = "jdbc:sqlserver://192.168.0.95;databaseName=sampleDB";

Also pass correct Username and password.

Related