a
This commit is contained in:
1 parent
655581b217
commit
ca531818f6
2 files changed
+81
-5
No files matched your search
+5
-5
@@ -21,15 +21,15 @@
|
|||||||
<option name="name" value="JBoss Community repository" />
|
<option name="name" value="JBoss Community repository" />
|
||||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="central" />
|
|
||||||
<option name="name" value="Central Repository" />
|
|
||||||
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="aliyun" />
|
<option name="id" value="aliyun" />
|
||||||
<option name="name" value="aliyun" />
|
<option name="name" value="aliyun" />
|
||||||
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
|
<option name="url" value="http://maven.aliyun.com/nexus/content/groups/public" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
# Java 连接 SQL Server 报错 TLS10
|
||||||
|
|
||||||
|
## 问题描述
|
||||||
|
|
||||||
|
在使用 **Java 8** 连接 **SQL Server 2008** 或老版本时,出现报错:
|
||||||
|
|
||||||
|
```
|
||||||
|
The server selected protocol version TLS10 is not accepted by client preferences [TLS12]
|
||||||
|
```
|
||||||
|
|
||||||
|
**原因**:
|
||||||
|
|
||||||
|
- SQL Server 2008 只支持 **TLS 1.0**
|
||||||
|
- Java 8 默认禁用 TLS 1.0/1.1(从某个更新版本起)
|
||||||
|
- 导致 SSL/TLS 握手失败
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
## 解决方案
|
||||||
|
|
||||||
|
### 方法 1:修改 `java.security` 配置文件
|
||||||
|
|
||||||
|
1. 打开文件:
|
||||||
|
|
||||||
|
```
|
||||||
|
<JDK_HOME>\jre\lib\security\java.security
|
||||||
|
```
|
||||||
|
|
||||||
|
1. 找到以下行:
|
||||||
|
|
||||||
|
```
|
||||||
|
jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, 3DES_EDE_CBC, ...
|
||||||
|
```
|
||||||
|
|
||||||
|
1. 删除 `TLSv1`、`TLSv1.1`,修改为:
|
||||||
|
|
||||||
|
```
|
||||||
|
jdk.tls.disabledAlgorithms=SSLv3, RC4, DES, MD5withRSA, \
|
||||||
|
DH keySize < 1024, EC keySize < 224, anon, NULL, \
|
||||||
|
include jdk.disabled.namedCurves
|
||||||
|
```
|
||||||
|
|
||||||
|
> ✅ 这样 JVM 启动后会允许 TLS 1.0,从而兼容 SQL Server 2008。
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
### 方法 2:在 JVM 启动参数中启用 TLS1.0(无需改文件)
|
||||||
|
|
||||||
|
```
|
||||||
|
-Djdk.tls.client.protocols=TLSv1,TLSv1.1,TLSv1.2
|
||||||
|
```
|
||||||
|
|
||||||
|
**用法示例**:
|
||||||
|
|
||||||
|
- IDEA VM options:
|
||||||
|
|
||||||
|
```
|
||||||
|
-Dfile.encoding=UTF-8 -Djdk.tls.client.protocols=TLSv1,TLSv1.1,TLSv1.2
|
||||||
|
```
|
||||||
|
|
||||||
|
- 命令行启动:
|
||||||
|
|
||||||
|
```
|
||||||
|
java -Djdk.tls.client.protocols=TLSv1,TLSv1.1,TLSv1.2 -jar yourapp.jar
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Navicat 连接 SQL Server 常见报错及解决方案
|
||||||
|
|
||||||
|
针对 Navicat 连接 SQL Server 2008/2008 R2 时可能出现的不同错误,整理成“错误 → 原因 → 解决”对照表,方便快速定位。
|
||||||
|
|
||||||
|
| 错误信息 | 原因 | 解决方案 |
|
||||||
|
| ------------------------------------------------------------ | ----------------------------------------- | ------------------------------------------------------------ |
|
||||||
|
| `[08001] [ODBC Driver 17 for SQL Server] SQL Server Network Interfaces: Connection string is not valid [87]` | 驱动不兼容老版本 SQL Server,连接格式不对 | 用 **Native Client 10.0** 驱动,填写正确服务器、端口、账号、数据库 |
|
||||||
|
| `[08001] [Microsoft][SQL Server Native Client 10.0] SQL Server 网络接口: 连接字符串无效 [87]` | 服务器不可达或连接格式错误 | 地址格式应 `192.168.1.100,1433`(逗号分隔),确保 TCP/IP 启用,端口开放 |
|
||||||
Reference in new issue
Block a user