今天,重新安装了新版的DataGrip 2026.1版本后,连接sql server,结果报了各种错误的。其实主要原因就是sql server 的版本低,驱动低导致的。怎么解决呢?
比如:DBMS: Microsoft SQL Server (ver. 13.00.5026) Case sensitivity: plain=mixed, delimited=mixed Driver: Microsoft JDBC Driver 11.2 for SQL Server (ver. 11.2.0.0, JDBC4.2)
The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "(unexpected_message) SQL Server did not return a response. The connection has been closed. ClientConnectionId:193019e6-4385-4f6e-bb13-2bc6f4b7e6a5".
DBMS: Microsoft SQL Server (ver. 13.00.5026)
Case sensitivity: plain=mixed, delimited=mixed
Driver: Microsoft JDBC Driver 11.2 for SQL Server (ver. 11.2.0.0, JDBC4.2)
"encrypt" property is set to "false" and "trustServerCertificate" property is set to "false" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: (unexpected_message) SQL Server did not return a response. The connection has been closed. ClientConnectionId:9dddd067-74bd-4fc5-9cba-ffc0d17ade5e.
1、首先最快的方式,肯定是要把驱动降下来,比如我本地的sql server是2016、服务器的是2013,所以经过不断的测试,最终只能支持10以下的版本(不包含)
2、如果版本降下来还是报“[08S01] 驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“(certificate_unknown) PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target”。 ClientConnectionId:8e390bef-39d7-48bd-82fb-bb9de41fbaec
unable to find valid certification path to requested target.””类似的错误或者"驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]……"等,那么还得需要改配置。即修改DataGrip安装目录下的\jbr\conf\security\java.security文件
将:
jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, DTLSv1.0, RC4, DES, \
MD5withRSA, DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
ECDH, TLS_RSA_*, rsa_pkcs1_sha1 usage HandshakeSignature, \
ecdsa_sha1 usage HandshakeSignature, dsa_sha1 usage HandshakeSignature
修改为:
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, anon, NULL
3、如果想要用高版本的驱动,提示:DBMS: Microsoft SQL Server (ver. 13.00.5026)
Case sensitivity: plain=mixed, delimited=mixed
Driver: Microsoft JDBC Driver 11.2 for SQL Server (ver. 11.2.0.0, JDBC4.2)
"encrypt" property is set to "false" and "trustServerCertificate" property is set to "false" but the driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption: Error: (unexpected_message) SQL Server did not return a response. The connection has been closed. ClientConnectionId:9dddd067-74bd-4fc5-9cba-ffc0d17ade5e.
则需要在连接URL后面添加如下配置:
encrypt=false;trustServerCertificate=true;如:jdbc:sqlserver://localhost\db:端口;database=db;encrypt=false;trustServerCertificate=true;
注意,用高版本的驱动,哪怕URL后面配置了encrypt=false;trustServerCertificate=true,也要修改java.security文件的jdk.tls.disabledAlgorithms值。