Connect to SQL Server from Linux via JDBC using integratedSecurity (Windows authentication)?

前端 未结 4 1800
情话喂你
情话喂你 2020-12-15 22:30

Hey I am having trouble connecting to an SQL Server with Java code that is running on Linux.

If I set integratedSecurity=true, then the java code fails

相关标签:
4条回答
  • 2020-12-15 22:50

    Adding authenticationScheme=JavaKerberos works for me in Linux, but make sure to remove integratedSecurity=true since you are not using Windows.

    0 讨论(0)
  • 2020-12-15 22:55

    You can't use integratedSecurity feature from Linux system, as it tied to windows system and uses your windows authentication. However, if you enable both SQL Server and Windows Authentication mode on your SQL Server, then you can create a login, map to corresponding database and use it in java from Linux.

    To enable SQL Server authentication:

    1. Right click on your server in management studio
    2. Properties
    3. Security
    4. Server authentication -> SQL Server and Windows Authentication mode
    0 讨论(0)
  • 2020-12-15 22:59

    If you want to use integrated security and using JDBC Driver 4.0 or greater then you add the following in your jdbc connection string.

    integratedSecurity=true;authenticationScheme=JavaKerberos
    

    More information: http://blogs.msdn.com/b/psssql/archive/2015/01/09/jdbc-this-driver-is-not-configured-for-integrated-authentication.aspx

    0 讨论(0)
  • 2020-12-15 23:01

    If you dont want Integrated Security connection, then set that parameter to false and instead provide user and password in the connURL as below:

    String connectionUrl = "jdbc:sqlserver://localhost:port;databaseName=DB_NAME;integratedSecurity=false;user=login_user;password=login_pwd;";
    
    0 讨论(0)
提交回复
热议问题