java 此驱动程序未配置为集成身份验证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32536608/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 20:20:46  来源:igfitidea点击:

This driver is not configured for integrated authentication

javasql-serverservletsglassfishsqljdbc

提问by Khairul Islam

Trying to connect my java web application with MS-SQL server using sqljdbc41for jdk 1.8. Here is the database connection code-

尝试使用sqljdbc41for将我的 Java Web 应用程序与 MS-SQL 服务器连接起来jdk 1.8。这是数据库连接代码-

    Connection connection;
    String url = "jdbc:sqlserver://localhost:1433;databaseName=Lista;integratedSecurity=true";
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    connection = DriverManager.getConnection(url);

when i am trying to insert some values to the database like-

当我尝试向数据库中插入一些值时,例如 -

    PreparedStatement ps = connection.prepareStatement("INSERT INTO user_informations VALUES(?,?,?)");

    ps.setString(1, "value");
    ps.setString(2, "value");
    ps.setString(3, "value");

    ps.executeUpdate();

getting the following error each time-

每次都收到以下错误-

com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication

com.microsoft.sqlserver.jdbc.SQLServerException: 此驱动程序未配置为集成身份验证

Here are some informations about what i have tried yet-

以下是有关我尝试过的内容的一些信息-

  • i have added the path of sqljdbc41in the path variable.
  • i have added the path of sqljdbc_auth.dllin the path variable.
  • i have added the sqljdbc41.jarinto my Nebeansproject library.
  • i have added the sqljdbc_auth.dllinto both bin folder under jdkand jre.
  • my jdkis 64 bitunder program files folder not in program file(x86).
  • jdbc driver folder is also in program file directory.
  • sql server and sql server browser services are also running.
  • sqljdbc41在路径变量中添加了路径。
  • sqljdbc_auth.dll在路径变量中添加了路径。
  • 我已将其添加sqljdbc41.jar到我的Nebeans项目库中。
  • 我已经添加了sqljdbc_auth.dll下到两个bin文件夹jdkjre
  • jdk就是64 bit在Program Files文件夹没有程序文件(x86)的。
  • jdbc 驱动程序文件夹也在程序文件目录中。
  • sql server 和 sql server 浏览器服务也在运行。

Edit

编辑

Now i experiencing a new thing-after restarting my pc when i deploy the project for the first time then it is working perfectly but when i make any change in my code and re-run the project it's not working!

现在我遇到了一个新事物 - 在我第一次部署项目时重新启动我的电脑后,它运行良好,但是当我对代码进行任何更改并重新运行该项目时,它无法正常工作!

采纳答案by Khairul Islam

I solved my problem!

我解决了我的问题!

The error (described in my question above) i was getting because the glassfishserver had not any access on sqljdbc42.jarfile. so i have placed the sqljdbc42.jarfile into my glassfishserver in this location-

我得到的错误(在我上面的问题中描述)是因为glassfish服务器没有任何sqljdbc42.jar文件访问权限。所以我已将sqljdbc42.jar文件放入我的glassfish服务器中的此位置-

glassfish-4.1\glassfish\domains\domain1\lib

glassfish-4.1\glassfish\domains\domain1\lib

And it's now working perfectly.

它现在运行良好。

Thank you everyone!

谢谢大家!

回答by demon36

The problem for me was that there were 2 java installations, one of them was the standard installation and it was 64bit, the other one was included in my oracle jdeveoper installation (it was the one used by the application giving that error) and surprisingly it was 32bit. I just put the correct dll in the java installation used by my application and everything went well

我的问题是有 2 个 java 安装,其中一个是标准安装,它是 64 位的,另一个包含在我的 oracle jdeveoper 安装中(它是应用程序使用的那个错误),令人惊讶的是它是 32 位的。我只是将正确的 dll 放在我的应用程序使用的 java 安装中,一切顺利

回答by MiguelSlv

sqljdbc_auth.dllis need to use windows authentication or Kerberos authentication.

sqljdbc_auth.dll需要使用 windows 身份验证或 Kerberos 身份验证。

Get the dll from Microsoftand install it either by:

Microsoft获取 dll并通过以下方式安装它:

  1. drop on application library folder
  2. drop on the java bin folder (attention if you have multiple java installations)
  3. drop the library on some folder and then add the path in the command line:

    java -Djava.library.path=<library path>...
    
  1. 放入应用程序库文件夹
  2. 放到 java bin 文件夹中(注意,如果你有多个 java 安装)
  3. 将库放在某个文件夹上,然后在命令行中添加路径:

    java -Djava.library.path=<library path>...
    

The mssql-jdbc driver and the auth dll should be:

mssql-jdbc 驱动程序和 auth dll 应该是:

  • on the same folder (but not mandatory)
  • both from the same version
  • for the same architecture (x86/x64) JVM is running.
  • 在同一个文件夹中(但不是强制性的)
  • 都来自同一个版本
  • 对于相同的架构 (x86/x64) JVM 正在运行。

Check also the jdbc compatibility matrix with java versions on the download page.

还可以在下载页面上检查 jdbc 与 java 版本的兼容性矩阵。