Vaish MK
Vaish MK

Reputation: 331

MSSQL jdbc - The driver could not establish a secure connection to SQL server using SSL encryption. Error: Unexpected rethrowing

I'm using springboot with Java 15. The version for the jdbc driver is not mentioned in the POM file.

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>

This is the application-prod.properties

spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.praperties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.datasource.url=jdbc:sqlserver://17x.1x.2x.8x:14xx; 
databaseName=xxxxxxaabcbx;
spring.datasource.username=xxxabcxUser
spring.datasource.password=xxxsxxssx

The similar configs run fine on the dev machine. But on the prod machine it works well but at some point it starts giving the error

Caused by: java.sql.SQLTransientConnectionException: HikariPool-l Connection not available, request timed out after 172291ms.
at com.zakker.hikari.pool.HikariPool.createTimeoutException (HikariFool.java:695)
at.com.zaxxer.hikari.pool.HikariPool.getConnection (HikariPool.java:197)
at com.zaxxer.hikari.pool.HikariPool.getConnection (HikariPool.java:162)
at com.zaxxer.hikari.HikariDataSource.getConnection (HikariDataSource.java:128)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection (DatasourceConnectionProviderImpl.java:122)
at org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection (NonContextual JdbcConnectionAccess.java:38)
at org.hibernate-resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded (LogicalConnectionManagedImpl.java:108)
131 common frames omitted

Caused by: secure connection to SQL Server by using Secure Sockets Layer (55L) encryption. **Error: "Unexpected rethrowing"**
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate (SQLServerConnection.java:3151) 
at com.microsoft.agleerver.jdbc.TD5Channel.enableSSL(IOBuffer.java:1912)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper (SQLServerConnection.java:2708)
at com.microsoft.agiserver.jdbc.SQLServerConnection. login (SQLServerConnection.java:2362) 
at com.microsoft.aqlserver.jdbc.SQLServerConnection.connectInternal (SQLServerConnection.java:2213)
at com.microsoft..sqlserver.jdbc.SQLServerConnection.connect (SQLServerConnection.java:1276)
at.com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:861)
at com.sanser.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zakner.hikari.pool.Poolbase.newConnection (FoolBase.java:358)
at com.saxxer.hikari.pool.PoolBase.newPoolEntry (PoolBase.java:206) com.zaxxer-hikari.pool.HikariPool.createPoolEntry (HikariPool.java:477)
at at com.zaxxer.hikari.pool, HikariPool.access100 (HikariPool.java:71)
at com.saxxer hikari.pool. Hikari Pools FoolEntryCreator.call (HikariPool.java:725) at com.saxxer/hikari.pool.RikersPool$PoolEntryCreator.doll (HikariPool.java:711)
at java.base/java.util.concurzent. FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1130) at java.bane/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)

Please help with why this is occuring only in the prod machine and why is it not giving the error right from the start? Is it due to the jdbc version not being mentioned in the pom?

Upvotes: -1

Views: 118

Answers (1)

Mario Mateaș
Mario Mateaș

Reputation: 1216

Read some comments and articles on how this can be due to the fact that the JDBC driver has an older version that doesn't support newer security features (newer TLS versions).

Try to also include a <version> tag with your JDBC dependency, and look for a newer one here: https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc

Usually, not including any version with your dependencies inside your pom.xml leads to compilation failures, but maybe this version comes from some <dependencyManagement> tag or a parent POM.

Upvotes: 0

Related Questions