Authenticating to a SQL Server instance as a Windows User via JDBC

后端 未结 9 1550
太阳男子
太阳男子 2020-12-06 06:37

I\'m having to support multiple database types for my tenant-enabled web application. Among others, I have successfully supported Microsoft\'s SQL Server, by using the net.s

9条回答
  •  我在风中等你
    2020-12-06 07:20

    I ran into the error

    The login is from an untrusted domain and cannot be used with Windows authentication

    when a 2012 SQL Server DB instance was recently upgraded to 2016. In order to use AD based authentication with the JTDS driver and SQL Server 2016, it seems necessary to specify both the useNTLMv2=true and the domain=example.com suffix in order to establish a connection. The name of the domain is absolutely necessary and I confirmed that through testing. This is with JTDS driver version 1.3.1.

    Example of a working connection string using AD based authentication to SQL Server 2016 DB with JTDS 1.3.1:

    jdbc:jtds:sqlserver://sqlserver2016db.example.com/MY_DB_NAME;domain=example.com;prepareSQL=2;useNTLMv2=true
    

提交回复
热议问题