fix(sqlserver): handle traditional chinese legacy fallback

Closes #8798
This commit is contained in:
t8y2
2026-09-27 08:14:01 +00:00
parent b22b6427e3
commit 7e2b74fb9d
2 changed files with 32 additions and 4 deletions
@@ -211,10 +211,14 @@ public final class SqlServerLegacyAgent extends ConfiguredJdbcAgent {
String normalized = message.toLowerCase(Locale.ROOT);
// mssql-jdbc rejects SQL Server 2000 (major version 8) during
// prelogin with "SQL Server version 8 is not supported by
// this driver." — the version word breaks a plain
// "sql server 8" substring match, so accept both shapes.
boolean version8Rejection = (normalized.contains("sql server 8") || normalized.contains("sql server version 8"))
&& (normalized.contains("not support") || normalized.contains("不支持"));
// this driver." Localized messages can translate the version
// and unsupported phrases, so accept those equivalent shapes.
boolean version8Rejection = (normalized.contains("sql server 8")
|| normalized.contains("sql server version 8")
|| normalized.contains("sql server 版本 8"))
&& (normalized.contains("not support")
|| normalized.contains("不支持")
|| normalized.contains("不支援"));
// Other driver wordings name the supported floor instead. The
// localized mssql-jdbc resource keeps "SQL Server 2005" in
// English while translating the "or later" suffix.
@@ -61,6 +61,30 @@ class SqlServerLegacyAgentTest {
));
}
@Test
void traditionalChineseSqlServer8RejectionsTriggerTheOldDriverFallback() {
Assertions.assertTrue(SqlServerLegacyAgent.shouldFallbackToJtds(
new SQLException("此驅動程式不支援 SQL Server 版本 8。")
));
Assertions.assertTrue(SqlServerLegacyAgent.shouldFallbackToJtds(
new SQLException("此驅動程式不支援 SQL Server 8 版。")
));
Assertions.assertTrue(SqlServerLegacyAgent.shouldFallbackToJtds(
new SQLException("此驅動程式不支援 SQL Server 版本 8.0。")
));
SQLException chained = new SQLException("連線失敗");
chained.setNextException(new SQLException("此驅動程式不支援 SQL Server 版本 8。"));
Assertions.assertTrue(SqlServerLegacyAgent.shouldFallbackToJtds(chained));
Assertions.assertFalse(SqlServerLegacyAgent.shouldFallbackToJtds(
new SQLException("登入失敗:SQL Server 版本 8 的使用者 'sa' 無法登入。")
));
Assertions.assertFalse(SqlServerLegacyAgent.shouldFallbackToJtds(
new SQLException("TLS 交握失敗:此驅動程式不支援 TLSv1。")
));
}
@Test
void jtdsUrlUsesLegacySqlServerSyntax() {
ConnectParams params = new ConnectParams(