【已解决】JDBC 接口连接 sqlserver 数据库问题

Viewed 69

版本:sqlserver2014
mysql> CREATE CATALOG sqlserver_test PROPERTIES (
-> "type"="jdbc",
-> "user"="cdc",
-> "password"="cdc",
-> "jdbc_url" = "jdbc:sqlserver://10.0.20.52:1433;databaseName=dbo;encrypt=false",
-> "driver_url" = "file:///opt/soft/doris/apache-doris-2.1.0-bin-arm64/mssql-jdbc-12.6.2.jre8.jar",
-> "driver_class" = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
-> );
Query OK, 0 rows affected (0.01 sec)

mysql> show databases from sqlserver_test;发生报错:

ERROR 1105 (HY000): Can not connect to jdbc due to error: com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not establish a secure connection to SQL Server by using Secure Sockets Layer (SSL) encryption. Error: "The server selected protocol version TLS10 is not accepted by client preferences [TLS13, TLS12]". ClientConnectionId:31a33a0e-40e6-4cfc-a358-b147c96dc7e5, Catalog name: sqlserver_test
mysql> show databases from sqlserver_test;
ERROR 1105 (HY000): Can not connect to jdbc due to error: com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 5000, active 0, maxActive 10, creating 0, createErrorCount 98, Catalog name: sqlserver_test

1 Answers

【问题状态】已记录
【问题处理】如下:

1、在 SQLServer 配置开启 TLS1.2 https://learn.microsoft.com/en-us/troubleshoot/sql/database-engine/connect/tls-1-2-support-microsoft-sql-server
2、打开 Jdk 的 TLS1.0 TLS1.1 支持 
      参考:https://www.cnblogs.com/qubernet/p/17994120
           https://blog.csdn.net/w605283073/article/details/126755540