【问题标题】:mssql-jdbc always throws The authenticationScheme NTLM is not validmssql-jdbc 总是抛出 The authenticationScheme NTLM is not valid
【发布时间】:2020-12-10 19:57:15
【问题描述】:
new SQLServerDriver();
String connectionUrl = "jdbc:sqlserver://<server>;integratedSecurity=true;authenticationScheme=NTLM;domain=<MYDOMAIN>;user=<user>;password=<password>;";
try (Connection con = DriverManager.getConnection(connectionUrl); Statement stmt = con.createStatement()) {
    String SQL = "select auth_scheme from sys.dm_exec_connections where session_id=@@spid";
    ResultSet rs = stmt.executeQuery(SQL);
    while (rs.next()) {
        System.out.println(rs.getString(1));
    }
}

这是我的操作系统和 Java 版本:

操作系统:Windows 10
openjdk 版本“1.8.0_242”
OpenJDK 运行时环境(内部版本 1.8.0_242-b08)
OpenJDK 64 位服务器 VM(内部版本 25.242-b08,混合模式)

不管字符串是“NTLM”还是“ntlm”等这条消息:

authenticationScheme "" 无效

这里肯定失败了 https://github.com/microsoft/mssql-jdbc/blob/dev/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java#L245

【问题讨论】:

  • 抱歉,我发现重现您的错误的唯一方法是将;authenticationScheme=\"\" 添加到连接字符串的末尾。但是,我注意到您的问题标题中的错误消息与您的问题正文中的错误消息不同,如果我在文本 NTLM 中包含 Unicode 零宽度空格 (\u200b),我可以重现该错误。这可能是你的问题吗?

标签: java sql-server jdbc ntlm


【解决方案1】:

我遇到了同样的问题。它通过使用最新的 jdbc 驱动程序版本mssql-jdbc-9.2.0.jre8.jar 解决。另外,请确保将 dll 文件 mssql-jdbc_auth-9.2.0.x64.dll 放在 lib 路径中。

【讨论】:

    猜你喜欢
    • 2018-03-24
    • 2012-09-15
    • 1970-01-01
    • 2012-09-11
    • 2020-07-21
    • 1970-01-01
    • 2011-04-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多