gpt4 book ai didi

java - I/O 错误 : SSO Failed: Native SSPI library not loaded

转载 作者:IT老高 更新时间:2023-10-28 21:04:52 28 4
gpt4 key购买 nike

我正在尝试运行以下代码:

import java.sql.DriverManager;

public class Connect {
public static void main(String[] args){
try{
String databaseDriver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(databaseDriver);
}
catch (Exception e) {
e.printStackTrace();
}

try{
String url = "jdbc:jtds:sqlserver://BHX:1433/Forecast;instance=SQLEPXRESS";
java.sql.Connection con = DriverManager.getConnection(url);
System.out.println("Connection");
}
catch (Exception e){
e.printStackTrace();
}
}
}

我的 SQL 服务器在机器 BHX 的 1433 端口上运行。

我得到的错误信息如下:

java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library not loaded. Check the     java.library.path system property.
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:615)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:352)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:185)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Connect.main(Connect.java:14)
Caused by: java.io.IOException: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property.
at net.sourceforge.jtds.jdbc.TdsCore.sendMSLoginPkt(TdsCore.java:1893)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:588)
... 6 more

我已经阅读了为什么通常会发生这种情况,并发现了一个类似的问题 here ,但这似乎不起作用。运行代码时,我包含以下参数来定位 SSO 文件:

-Djava.library.path=/Tester/jdbc/x64/SSO

这是我文件的结构

**Tester**
*src*
default package
Connect.java
*JRE System Library*
*jdbc*
conf
html
IA64
x64
SSO
ntlmauth.dll
x86

你能看出什么不对吗?

最佳答案

似乎与此问题相同:jtds-driver-not-working-for-sql-sever-2008r2-and-denali-native-sspi-library-not

您应该从 JTDS download package 中删除适当的 ntlmauth.dll 文件。进入您的 JRE bin 文件夹。

如果您在 64 位 Windows 机器上运行:

  • 这个 32 位 DLL:

    Downloads >>> jtds-1.3.0-dist.zip >>> x86 >>> SSO >>> ntlmauth.dll

  • 进入这个 32 位 JRE 位置:

    C:\Program Files (x86)\Java\jre7\bin

  • 这个 64 位 DLL:

    Downloads >>> jtds-1.3.0-dist.zip >>> x64 >>> SSO >>> ntlmauth.dll

  • 进入这个 64 位 JRE 位置:

    C:\Program Files\Java\jre7\bin

如果您在 32 位 Windows 机器上运行:

  • 这个 32 位 DLL:

    Downloads >>> jtds-1.3.0-dist.zip >>> x86 >>> SSO >>> ntlmauth.dll

  • 进入这个 32 位 JRE 位置:

    C:\Program Files\Java\jre7\bin

如果这不起作用,请尝试在 main 方法的顶部添加这一行:System.out.println(java.lang.System.getProperty('java.library.path'));

它应该输出您的程序正在使用的实际 JRE 路径。确保相应的 ntlmauth.dll 在该 JRE 的 bin 文件夹中。

注意:使用此方法时,请勿设置连接的域、用户或密码属性。

注意:如果您的 Java 客户端程序在非 Windows 机器上运行,那么使用 ntlmauth.dll 方法会很不走运。这是来自 JTDS 下载包中包含的文档的引用:下载 >>> jtds-1.3.0-dist.zip >>> README.SSO

Starting with release 0.9.2 jTDS is capable of using the Windows credentials of the current user under whose account the client program is running to login to SQL Server (Windows Single Sign On).

Using Windows Single Sign On (SSO) clients will be able to connect to Microsoft SQL Server without providing credentials. It would dynamically read current user's credentials and connect to the database. provided that the Windows account has enough rights in the database. This is done using a native (Windows-only) library, ntlmauth.dll.

关于java - I/O 错误 : SSO Failed: Native SSPI library not loaded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13267764/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com