无法将spring启动应用程序与sql server数据库连接

svgewumm  于 2021-07-12  发布在  Java
关注(0)|答案(2)|浏览(490)

我正在尝试将我的spring boot应用程序与sql server数据库连接,但它引发了一个异常并说:

020-08-18 16:58:11.580 ERROR 14800 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

    com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. .

但是,当我尝试连接sql server时,我可以连接到oracle数据库。
这是application.properties文件

spring.datasource.url=jdbc:sqlserver://192.168.*.*\\DB2008;databaseName=mydbname
spring.datasource.username=myuser
spring.datasource.password=mypassword
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect

下面是详细的错误:

2020-08-18 16:58:11.580 ERROR 14800 --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Exception during pool initialization.

com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "SQL Server did not return a response. The connection has been closed. ClientConnectionId:37aa16bd-92f0-4af0-a090-06f2349cb51a".
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2924) ~[mssql-jdbc-7.4.0.jre8.jar:na]
    at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1881) ~[mssql-jdbc-7.4.0.jre8.jar:na]
    at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2484) ~[mssql-jdbc-7.4.0.jre8.jar:na]
zwghvu4y

zwghvu4y1#

在这种情况下,您可以尝试以下步骤。
确保您的sql server正在本地运行(您是否正在尝试连接到删除sql server?)
或者,在数据库名称后面的url中使用以下语句 jdbc:mysql://IP:3306/someDatabase?autoReconnect=true&useSSL=false

f0brbegy

f0brbegy2#

我已通过以下步骤解决此问题:
编辑c:\program files\java\jdk1.8.0\U 251\jre\lib\security\java.security
找到下面的变量,它将有多个逗号分隔的值删除我在下面提到的一个值:
查找:jdk.tls.disabledalgorithms=
删除:3des\u ede\u cbc
这应该可以解决它!

相关问题