【问题标题】:JTDS error: Native SSPI library not loadedJTDS 错误:未加载本机 SSPI 库
【发布时间】:2017-02-07 17:38:38
【问题描述】:

我已经多次看到这个问题出现了,但我尝试过的所有答案都对我不起作用。以前的连接字符串看起来像这样

url = "jdbc:jtds:sqlserver://server1/dbname;user=user;password=pswd"; //this one works fine
url = "jdbc:jtds:sqlserver://server1;dbname;databaseName=dbname;integratedSecurity=true"; //doesn't work

但我得到了例外。

java.io.IOException: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.

我有 jtds 1.2,我将 ntlmauth.dll 复制到我的 lib 文件夹,并在 eclipse 上添加了 jtd-1.2.jar 的本机库位置的路径,但没有任何改变。

还尝试将 -Djava.library.path=./lib 添加到我的运行配置中。我正在使用 jre 1.7 和 Eclipse Helios 运行 RCP 应用程序

【问题讨论】:

  • 我还将 ntlmauth.dll 添加到 C:\Program Files\Java\jre7\bin

标签: java sql-server eclipse jtds


【解决方案1】:

我改用 Microsfot JDBC 驱动程序使我的程序正常工作。从他们的网站下载

https://www.microsoft.com/en-us/download/details.aspx?id=11774

并从连接字符串中删除 jtds

url = "jdbc:jtds:sqlserver://server1;dbname;databaseName=dbname;integratedSecurity=true";

【讨论】:

    【解决方案2】:

    我遇到了同样的问题。

    通常我会做这样的事情,效果很好:

    myConnection = DriverManager.getConnection(dbConnection, "username", "pasword");
    

    但是当尝试通过这样的方法获取用户名和密码时:

    myConnection = DriverManager.getConnection(dbConnection, getUser(), getPassword());
    

    我遇到了同样的错误。原来getUser() 正在返回null,这似乎使SQL Server 尝试使用Windows 身份验证登录,而这并没有在该机器上设置。因此,请确保 getUser() 不是 null 有所作为。

    【讨论】:

      猜你喜欢
      • 2012-10-27
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-15
      • 2020-06-02
      • 2014-07-25
      • 2018-04-17
      相关资源
      最近更新 更多