I was connecting to Sql Server 2008 & 2008+ via Java program with
- Java 8
- Sql jdbc microsoft driver 4.1
- Connection string:
DriverManager.getConnection("jdbc:sqlserver://<Ip>;instance=MSSQLSERVER;domain=<domain>;IntegratedSecurity=true;ssl=request;", "administrator", "password");
I was able to connect successfully. However when I enabled Force encryption to true in the sql server via sql server configuration manager.
I started getting following error.
com.microsoft.sqlserver.jdbc.SQLServerException: An existing connection was forcibly closed by the remote host ClientConnectionId:xxxx
FYI: I have already tried adding below parameters in connection string.
- ssl=request
- ssl=require
- encrypt=true
- trustServerCertificate=true
- Also I have tried upgrading the driver to 4.2 & mssql driver 7.0
- Tried jtds driver as well
- Point to be noted: I am able to connect to instance via ssms
EDIT 1
- Another important point - It's happening only for windows authentication (enabled via IntegratedSecurity=true; in connection string). So this case is happening only when Force encryption is set to true and we try to connect in windows authentication mode.

