Solution
Add after the connected url; trustServerCertificate=true
as follows
spring:
datasource:
url: jdbc:sqlserver://localhost:1433;DatabaseName=数据库名称;trustServerCertificate=true
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
username: 账号
password: 密码
Mental journey
Our company uses sql server. When I was preparing for an internship in my senior year, I learned springtboot, and the company used the sql server connected to vs studio. I don't want to use vs studio, because I think at least one technology will be used first, and I will be proficient in one technology. Our team leader said yes, as long as the problem can be solved, but the usual work cannot be left behind, and we have time to think on our own. The team leader also said that technology is just technology, don't resist learning old technology, just learn what you don't want to get angry, if you can solve the problem, I don't care about you.
The first step, idea connects to sql server
Then it reported an error, SSL encryption error.
The solution is as follows in
the blog garden . Now I only see two likes, and the other is mine. I also specially registered a blog garden.
my own summary
The second step is to use springboot to connect to sql server
I found that the same error was reported, and what is on the Internet is to modify the code in sercurity.java in jdk. Download the jdk version specially connected to sql server. This is too troublesome and unreasonable. Could it be that I have restricted all other versions of jdk, springboot, etc. even with sql server, I have to try other methods. Then it is a direct test to add trustServerCertificate=true after the url, separated by semicolons. In the end, I didn't expect that the login timed out. Then I found out that there was something wrong with the database I was connecting to.
The third step is to solve the connection problem and get the database data
Use postman to get the data