我正在尝试在 IntelliJ 中运行一个小型测试程序。代码:
String driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String url = "jdbc:sqlserver://test.test.com;integratedSecurity=true";
String userName = "test";
String password = "test";
Class.forName(driverClass);
try (Connection con = DriverManager.getConnection(url, userName, password);
Statement st1 = con.createStatement();
Statement st2 = con.createStatement();
) {
String sql1 = "EXEC [dbo].[Cleanup]";
String sql2 = "EXEC [dbo].[DetailsALL] \"DetailsALL.csv\" ";
st1.execute(sql1);
st2.execute(sql2);
}catch(Exception e){
System.out.println(e.getMessage());
}
我在 VM 选项中添加了以下内容:
-Djava.library.path="\Users\sgupta\IdeaProjects\todos\sqljdbc_4.0\enu\auth\x86\"
运行程序会导致:
2013 年 4 月 5 日下午 5:43:20 com.microsoft.sqlserver.jdbc.AuthenticationJNI 警告:无法加载 sqljdbc_auth.dll 原因:java.library.path 中没有 sqljdbc_auth 此驱动程序未配置为集成身份验证。 ClientConnectionId:db8a3aa3-d84b-49d2-a7eb-64c4187a8303
我已经仔细检查了我在 VM 选项中指定的路径。还有其他建议吗?谢谢。
最佳答案
看来我有一些坏消息要告诉你。这直接来自 .tar.gz 文件中包含的 sqljdbc 文档。打包文件后,转到此帮助网页:sqljdbc_4.0/enu/help/default.htm
在目录下 >>> 使用 JDBC 驱动程序连接到 SQL Server >>> 构建连接 URL,转到部分:“使用集成身份验证连接”
在本节的底部有以下引用,它基本上表示您不能将 dll 方法用于非 Windows 系统。
The JDBC driver does not support the integrated authentication when the driver runs on non-Windows operating systems. The driver also does not provide any functionality to supply Windows Authentication credentials, such as user name and password, when connecting to SQL Server from non-Windows operating systems. In such cases, the applications must use SQL Server Authentication instead.
但是,这个帮助文件的等效 msdn 文档似乎表明,对于所有非 Windows 操作系统,您都可以让它与 Kerberos 一起使用。 http://msdn.microsoft.com/en-us/library/ms378428.aspx
此 msdn 链接提供了 Kerberos 进程的概述,但它缺乏针对非 Windows 机器的详细设置。 http://msdn.microsoft.com/en-us/library/gg558122.aspx
如果有人知道如何让 Kerberos 从非 Windows 机器连接到 SQL Server 的详细信息,我很想听听他们的意见。
关于sql-server - JDBC/IntelliJ 加载 sqljdbc_auth.dll 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15844875/