我正在使用Microsoft SQL Server 2008,并试图使用JDBC连接到数据库。以下是我的代码。用户名和密码使用Windows身份验证。如何使用JDBC连接到SQL Server
String url1 = "jdbc:sqlserver://ServerName;databaseName=v14testvp;user=USERNAME;password='';";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
DriverManager.getConnection(url1);
试图连接
com.microsoft.sqlserver.jdbc.SQLServerException当我收到打击错误:用户登录失败 'USERNAME'。 ClientConnectionId:befb617f-8382-4388-ad98-a210ed0c3105
有人可以帮我解决什么问题来解决错误。我已经尝试填写我的url1字符串中的用户名和密码,但我得到了同样的错误。我也尝试在用户名(domain \ USERNAME)中包含域。我相对较新的SQL和Java,所以希望我只是想念一些简单的东西。
编辑:
我改变了我的代码下面
String url1 = "jdbc:sqlserver://servername;databaseName=v14testvp;integratedSecurity=true;authenticationScheme=JavaKerberos";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
DriverManager.getConnection(url1);
我现在得到以下错误。我有sqljdbc_auth.dll。有人能指出我如何解决这个问题的正确方向吗?
com.microsoft.sqlserver.jdbc.SQLServerException:集成验证失败。 ClientConnectionId:0e66f60e-958c-4c8e-85b9-484023f16ecf at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1667) at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:140 ) 在com.microsoft.sqlserver.jdbc.KerbAuthentication.GenerateClientContext(KerbAuthentication.java:268) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2691) 在com.microsoft.sqlserver.jdbc .SQLServerConnection.logon(SQLServerConnection.java:2234) at com.microsoft.sqlserver.jdbc.SQLServerConnection.access $ 000(SQLServerConnection.java:41) at com.microsoft.sqlserver.jdbc.SQLServerConnection $ LogonCommand.doExecute(SQLServerConnection。 java:2220) at com.micros oft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper( SQLServerConnection.java:1326) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:991) 在com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:827) 在COM。 microsql.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at com.ibm.atmn。 tests.DumbyClass.DumbyTests(DumbyClass.java:52) 引起者:jav ax.security.auth.login.LoginException:无法获得Princpal名认证
com.microsoft.sqlserver.jdbc.SQLServerException:登录失败,用户 'USERNAME'。 1)确保用户名/密码正确。 2)如果您正在从远程机器访问,请确保授予远程访问 – kosa
@Nambari - 用户名/密码正确,远程访问被授予 – TestRaptor
@TestRaptor您是否找到解决该问题的方法? –