Hey I am having trouble connecting to an SQL Server with Java code that is running on Linux.
嘿,我无法使用在Linux上运行的Java代码连接到SQL Server。
If I set integratedSecurity=true
, then the java code fails with the following error:
如果我设置integratedSecurity = true,那么java代码将失败,并显示以下错误:
WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:b030b480-453d-4007-8151-a552150f74cd
which makes sense as there will be no sqljdbc.dll
file on Linux.
这是有道理的,因为Linux上没有sqljdbc.dll文件。
But if I set integratedSecurity=false
, then I get the following error:
但是如果我设置integratedSecurity = false,那么我会收到以下错误:
com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'IT_DEV_USER'.
So does anyone know how I can connect to SQL Server with integratedSecurity
set to false? (Note that I cant even connect when the Java code is running on Windows when integratedSecurity
is set to false.)
那么有谁知道如何连接到SQL Server并将integratedSecurity设置为false? (请注意,当IntegratedSecurity设置为false时,我甚至无法在Windows上运行Java代码时进行连接。)
If not, is there any way I can get integratedSecurity
working on Linux?
如果没有,有什么办法可以让我在Linux上运行integratedSecurity吗?
4 个解决方案
#1
4
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.
如果要使用集成安全性并使用JDBC Driver 4.0或更高版本,则在jdbc连接字符串中添加以下内容。
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
更多信息:http://blogs.msdn.com/b/psssql/archive/2015/01/09/jdbc-this-driver-is-not-configured-for-integrated-authentication.aspx
#2
0
Adding authenticationScheme=JavaKerberos
works for me in Linux, but make sure to remove integratedSecurity=true
since you are not using Windows.
添加authenticationScheme = JavaKerberos在Linux中适用于我,但请确保删除integratedSecurity = true,因为您没有使用Windows。
#3
0
If you dont want Integrated Security connection, then set that parameter to false and instead provide user and password in the connURL as below:
如果您不想要集成安全性连接,请将该参数设置为false,而是在connURL中提供用户和密码,如下所示:
String connectionUrl = "jdbc:sqlserver://localhost:port;databaseName=DB_NAME;integratedSecurity=false;user=login_user;password=login_pwd;";
#4
-2
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.
您无法使用Linux系统中的integratedSecurity功能,因为它与Windows系统绑定并使用您的Windows身份验证。但是,如果在SQL Server上同时启用SQL Server和Windows身份验证模式,则可以创建登录名,映射到相应的数据库并在Linux中使用它。
To enable SQL Server authentication:
要启用SQL Server身份验证:
- Right click on your server in management studio
- 右键单击管理工作室中的服务器
- Properties
- 属性
- Security
- 安全
- Server authentication -> SQL Server and Windows Authentication mode
- 服务器身份验证 - > SQL Server和Windows身份验证模式
#1
4
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.
如果要使用集成安全性并使用JDBC Driver 4.0或更高版本,则在jdbc连接字符串中添加以下内容。
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
更多信息:http://blogs.msdn.com/b/psssql/archive/2015/01/09/jdbc-this-driver-is-not-configured-for-integrated-authentication.aspx
#2
0
Adding authenticationScheme=JavaKerberos
works for me in Linux, but make sure to remove integratedSecurity=true
since you are not using Windows.
添加authenticationScheme = JavaKerberos在Linux中适用于我,但请确保删除integratedSecurity = true,因为您没有使用Windows。
#3
0
If you dont want Integrated Security connection, then set that parameter to false and instead provide user and password in the connURL as below:
如果您不想要集成安全性连接,请将该参数设置为false,而是在connURL中提供用户和密码,如下所示:
String connectionUrl = "jdbc:sqlserver://localhost:port;databaseName=DB_NAME;integratedSecurity=false;user=login_user;password=login_pwd;";
#4
-2
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.
您无法使用Linux系统中的integratedSecurity功能,因为它与Windows系统绑定并使用您的Windows身份验证。但是,如果在SQL Server上同时启用SQL Server和Windows身份验证模式,则可以创建登录名,映射到相应的数据库并在Linux中使用它。
To enable SQL Server authentication:
要启用SQL Server身份验证:
- Right click on your server in management studio
- 右键单击管理工作室中的服务器
- Properties
- 属性
- Security
- 安全
- Server authentication -> SQL Server and Windows Authentication mode
- 服务器身份验证 - > SQL Server和Windows身份验证模式