cant connect sql with android studio app error shows SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption

mario 1 Reputation point
2020-10-30T14:30:53.767+00:00

SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption.

-i'm using driver in android studio build implementation project(path: ':mssql-jdbc-6.1.0.jre7')

Complete Code-url="jdbc:sqlserver://serverName.database.windows.net:1433;DatabaseName=sampleDatabase;user=user@Testta ;password=pass;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();  
    StrictMode.setThreadPolicy(policy);  
    try {  
        Connection conn = DriverManager.getConnection(url);  
        System.out.println("connection "+conn);  
        Statement sttete = conn.createStatement();  
        ResultSet qqq = sttete.executeQuery("select * from users");  
    } catch (SQLException e) {  
        e.printStackTrace();  
        System.out.println("error During Get Connection.....././././. "+e);  
    }  
Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. Sy, Hung 0 Reputation points
    2023-06-02T21:40:43.4366667+00:00

    I have same problem. Is there a solution to this issue?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.