Error 'com.microsoft.sqlserver.jdbc.SQLServerException Login failed for user' When Trying to Retrieve Data from a Microsoft SQL Server Database Issue The ServiceNow instance can retrieve data from a Microsoft SQL Server database via JDBC configured in a Data Source. Some customers have reported seeing errors similar to this, even when the Data Source record has correct details and credentials for the user ('TESTUSER\svc-sccm-snowtest' in this example): Data source: SCCM 2016 NetworkError: java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'TESTUSER\svc-sccm-snowtest'. ClientConnectionId:76194d006-988f-4814-aec1-366o28bfb62ccom.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216)com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:254)com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:84)com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2908)com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:2234)com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41)com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:2220)com.microsoft.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.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:1012)java.sql.DriverManager.getConnection(DriverManager.java:664)java.sql.DriverManager.getConnection(DriverManager.java:208)com.service_now.mid.connections.jdbc.JDBCConnection.establishConnection(JDBCConnection.java:102)com.service_now.mid.connections.jdbc.JDBCConnection.connect(JDBCConnection.java:74)com.service_now.mid.connections.jdbc.JDBCConnectionFactory.create(JDBCConnectionFactory.java:65)com.service_now.mid.connections.ConnectionCachePool.getAvailableConnection(ConnectionCachePool.java:82)com.service_now.mid.connections.ConnectionCache.get(ConnectionCache.java:94)ReleaseAll ServiceNow releases. This issue may be seen when connecting to a Microsoft SQL Server database via JDBC, including with integrations that use this functionality such as the (deprecated) SCCM 2016 integration or the (current) Service Graph SCCM integrationCauseThe SQL Server database rejects the login attempt even if the username and password are correct because it requires Windows Integrated Authentication. This means that the credentials of the Windows user which the ServiceNow MID server Windows Service runs as needs to be used to access the SQL Server Database.ResolutionOn the MID Server side: Go to your MID Server machine and access ServicesGo to the Service for the MID ServerGo to the Log On tab of the serviceSet the service to use the domain account, for example: TESTUSER\svc-sccm-snowtestEnter the passwordRestart the service. On the ServiceNow instance: Go to the DatasourceSet Use integrated authentication to trueSave the record. Note that it may be necessary to also change the JDBC connection string to specify integratedSecurity=true, for example: jdbc:sqlserver://database-server.example.com:1433;selectMethod=cursor;databaseName=exampledb;integratedSecurity=trueRelated LinksEach MID Server Can Only Run as One Windows User Account In order to use this MID Server for other integrations, you must connect with the target database with the exact account in the MID Server or the other database must be set to not require integrated authentication. So, if you have other SQL connections that require integrated authentication and the user account is different, you must use a different MID Server for those connections. The MID Server Windows service can only run as a single user account. 'The login is from an untrusted domain' Error Sometimes when using Integrated Authentication customers will see this error: java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed. The login is from an untrusted domain and cannot be used with Windows authentication. ClientConnectionId:123f7398-5f29-2649-b807-c39889365cfecom.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262) This has been seen by customers when setting up a new MID server in a different location - for example when setting up a new MID on an AWS EC2 instance when the existing MID was on-premise. This is not a ServiceNow issue and customers would need to work with the admins for their AD and SQL Server environments to resolve this.