application.properties文件数据连接配置为:
# sqlserver数据源2:前缀为:spring.datasource.sqlserver
jdbc.er.driverClassNam=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.er.url=jdbc:sqlserver://172.0.0.1:1433;database=demo
jdbc.er.username=mydemo
jdbc.er.password=1234test
报错:
ERROR 2696 --- [nio-8080-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”。 ClientConnectionId:…… with root cause
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141) ~[na:na]文章来源:https://www.toymoban.com/news/detail-537087.html
原因是 sqlserver jdbc驱动默认要求使用ssl链接来保证安全性
配置文件修改如下:
jdbc.er.url=jdbc:sqlserver://172.0.0.1:1433;database=demo;trustServerCertificate=true
解决该问题
文章来源地址https://www.toymoban.com/news/detail-537087.html
到了这里,关于springboot 使用 microsoft SQL server 报错的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!