而连接MSSQL服务器从JDBC Windows身份验证问题

问题描述 投票:2回答:1

试图通过Windows身份验证从Linux机器上运行的Java应用程序连接到MS SQL服务器。连接字符串:

JDBC:SQLSERVER://192.168.1.50 \ SQLEXPRESS:1433;数据库名=迈德特; integratedSecurity = TRUE; authenticationScheme = JavaKerberos

有连接错误:

com.microsoft.sqlserver.jdbc.SQLServerException: Integrated authentication failed. ClientConnectionId:42aee675-fd0d-489e-af73-574ae5c304fa
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2670) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.KerbAuthentication.intAuthInit(KerbAuthentication.java:131) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.KerbAuthentication.GenerateClientContext(KerbAuthentication.java:399) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4306) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3409) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3373) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7344) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) ~[mssql-jdbc-6.4.0.jre8.jar:?]
       at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) ~[mssql-jdbc-6.4.0.jre8.jar:?]

如何理解这种错误,以及如何解决它?

UPD

如果我删除authenticationScheme=JavaKerberos如下:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS:1433;DatabaseName=MyData;integratedSecurity=true;

我有错误:

java.sql.SQLException: No suitable driver found for
       at java.sql.DriverManager.getConnection(DriverManager.java:689) ~[?:1.8.0_171]
       at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_171]

UPD 2

离开authenticationScheme=JavaKerberos和如下除去integratedSecurity=true

jdbc:sqlserver://192.168.1.50\SQLEXPRESS:1433;DatabaseName=MyData;authenticationScheme=JavaKerberos

给出错误:

com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'myuser'. ClientConnectionId:42aee675-fd0d-489e-af73-574ae5c304fa
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:256) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:108) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:4548) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3409) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:85) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3373) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7344) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2713) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2261) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1921) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1762) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1077) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:623) ~[mssql-jdbc-6.4.0.jre8.jar:?]
        at java.sql.DriverManager.getConnection(DriverManager.java:664) ~[?:1.8.0_171]
        at java.sql.DriverManager.getConnection(DriverManager.java:247) ~[?:1.8.0_171]
java sql-server jdbc kerberos
1个回答
0
投票

Linux机器上的应用程序运行,是计算机加入到Windows域?

如果没有,那么你可能需要使用SQL身份验证:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS;user=MyUserName;password=*****;

否则,这样一来尝试没有指定authenticationScheme=JavaKerberos和默认端口:

jdbc:sqlserver://192.168.1.50\SQLEXPRESS;DatabaseName=MyData;integratedSecurity=true;
© www.soinside.com 2019 - 2024. All rights reserved.