Detailed Explanation: The driver cannot establish a secure connection with SQL Server by using Secure Sockets Layer (SSL) encryption.

1. Problem Analysis

The SSL protocol provides services mainly:

  1. Authenticating user servers to ensure data is sent to the correct server.
  2. Encrypt data to prevent data from being stolen during transmission
  3. Maintain data integrity and verify that data is not lost in transit

It is not recommended to establish an SSL connection without server authentication. As required by MySQL 5.5.45+, 5.6.26+, and 5.7.6+, a default SSL connection must be established if no explicit option is set. SSL needs to be explicitly disabled by setting useSSL=false , or set useSSL=true and provide a trust store for server certificate verification.

2. java to connect to the MySQL database

Modify the url, adduseSSL=false

jdbc:mysql://localhost:3306/数据库名?useSSL=false

3.java connects to the SQL Server database

3.1 Create a security file

The file name can be customized, here I will name it security

It is recommended that the file does not have a suffix, and a txt text file can be created first. Paste the following into the file:

jdk.tls.disabledAlgorithms=SSLv3, 3DES_EDE_CBC, DES, MD5withRSA, \
    DH keySize < 1024, EC keySize < 224, anon, NULL, \
    include jdk.disabled.namedCurves

After saving the file, rename the file to remove .txt the suffix.

The path of this security file needs to be known, my path isD:\security

image-20221128003948044

3.2 Add parameters to the project that needs to be run

image-20221116123759490

image-20221116123847209

image-20221116124033931

Parameter format added to VM:"-Djava.security.properties=The security file path just created"

Here I am: "-Djava.security.properties=D:\security"( Note to write double quotes )

image-20221116124238759

At this time, it will be no problem to run the project again.

Guess you like

Origin blog.csdn.net/qq_62982856/article/details/127883056