I am trying to connect my spring boot application with sql server database but it throwing an Exception and saying :
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. .
However I am able to connect with oracle database the issue arises when I try to connect with sql server.
here is the application.properties file
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
here is the detailed error:
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]
I have resolved this issue by following the below steps:
Edit C:\Program Files\Java\jdk1.8.0_251\jre\lib\security\java.security
find the below variable it will have multiple comma separated values remove one value which I have mentioned below:
Find: jdk.tls.disabledAlgorithms=
Remove: 3DES_EDE_CBC
This should fix it!