i must connect to a sql server with windows authentication
我必须使用Windows身份验证连接到SQL Server
sql server is on machine 192.168.3.6 web server (client) is on my machine 192.168.3.10
sql server在机器192.168.3.6上.Web服务器(客户端)在我的机器192.168.3.10上
I'm using JTDS driver
我正在使用JTDS驱动程序
dbUrl=jdbc:jtds:sqlserver://192.168.3.6:1099/db_test;instance=test
Connection con = DriverManager.getConnection( dbUrl, "", "" );
I have username and password of administrator user of sql server !
我有sql server管理员用户的用户名和密码!
I also put ntlmauth.dll
into c:\windows
and c:\windows\system32
and I have always error:
我还将ntlmauth.dll放入c:\ windows和c:\ windows \ system32,我总是出错:
java.sql.SQLException: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server connection.
java.sql.SQLException:用户'(null)'登录失败。原因:与受信任的SQL Server连接无关。
Any idea to solve my problem ? Thank you very much
有什么想法来解决我的问题吗?非常感谢你
2 个解决方案
#1
36
See jTDS FAQ http://jtds.sourceforge.net/faq.html
请参阅jTDS FAQ http://jtds.sourceforge.net/faq.html
you will have to pass useNTLMv2=true
and domain=yourdomain
你必须传递useNTLMv2 = true和domain = yourdomain
#2
3
What you can do is something like:
你能做的是:
String url = "jdbc:jtds:sqlserver://MYPC/MYDB;instance=SQLEXPRESS";
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(url);
Make sure you have jtds.jar in the Java build path.
确保在Java构建路径中有jtds.jar。
Also, add "-Djava.library.path="PATH\JTDS\x64\SSO" where 'Path' is where your SSO folder is after installing the JTDS driver (this is where you have your ntlmauth.dll).
另外,添加“-Djava.library.path =”PATH \ JTDS \ x64 \ SSO“其中'Path'是您安装JTDS驱动程序后SSO文件夹所在的位置(这是您拥有ntlmauth.dll的地方)。
Here is a short step-by-step guide showing how to connect to SQL Server using jTDS (as well as JDBC) with Windows authentication should you need more details. Hope it helps!
以下是一个简短的分步指南,展示如何使用jTDS(以及JDBC)与Windows身份验证连接到SQL Server,如果您需要更多详细信息。希望能帮助到你!
#1
36
See jTDS FAQ http://jtds.sourceforge.net/faq.html
请参阅jTDS FAQ http://jtds.sourceforge.net/faq.html
you will have to pass useNTLMv2=true
and domain=yourdomain
你必须传递useNTLMv2 = true和domain = yourdomain
#2
3
What you can do is something like:
你能做的是:
String url = "jdbc:jtds:sqlserver://MYPC/MYDB;instance=SQLEXPRESS";
Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection conn = DriverManager.getConnection(url);
Make sure you have jtds.jar in the Java build path.
确保在Java构建路径中有jtds.jar。
Also, add "-Djava.library.path="PATH\JTDS\x64\SSO" where 'Path' is where your SSO folder is after installing the JTDS driver (this is where you have your ntlmauth.dll).
另外,添加“-Djava.library.path =”PATH \ JTDS \ x64 \ SSO“其中'Path'是您安装JTDS驱动程序后SSO文件夹所在的位置(这是您拥有ntlmauth.dll的地方)。
Here is a short step-by-step guide showing how to connect to SQL Server using jTDS (as well as JDBC) with Windows authentication should you need more details. Hope it helps!
以下是一个简短的分步指南,展示如何使用jTDS(以及JDBC)与Windows身份验证连接到SQL Server,如果您需要更多详细信息。希望能帮助到你!