Connection error on SQL Server : DB server closed connection

Connection error on SQL Server : DB server closed connection

Symptom

Error message :

SQL Server : Error : java.io.IOException: DB server closed connection

Where to find the information :

When connecting 360Suite / 360Eyes to SQL Server database

Environment

  • Product : 360Suite / 360Eyes

  • Product Version : All

  • Database : SQL Server 2017 (and higher versions)

Cause

TLS encryption implementation in SQL Server has changed starting version 2017.

All the SQL Server versions can support TLS encryption during the connection but version 2016 and earlier need some additional local configuration, whereas version 2017 and later include it natively (SQL Server side).

You can check the following link to know more about this change :

Resolution


If you encounter this error message during the connection to SQL Server 2017 or higher, it means that your JDBC URL is not compliant with what is expected by SQL Server.
TLS being natively implemented, you will have to use the following JDBC URL format to bypass the local certificate verification and rely on the security method offered by SQL Server :

jdbc:sqlserver://<host>:<port>;databaseName=<db>;encrypt=true;trustServerCertificate=true
 
Here's a Microsoft article about this specific parameter :