SQLException:此驱动程序未配置为集成身份验证tomcat [英] SQLException: this driver is not configured for integrated authentication tomcat

查看:1388
本文介绍了SQLException:此驱动程序未配置为集成身份验证tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试通过java Web应用程序连接MS SQL服务器。

Am trying to connect MS SQL server through java web applications.

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

connection= DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=XXX;integratedSecurity=true");

我已将sqljdbc_auth.dll复制到$ Tomcat_home / bin并将jar复制到$ Tomcat_home / lib文件夹。

我在同一个tomcat实例中有多个Web应用程序。

I Have multiple web apps in same tomcat instance.

第一个webApp加载并成功建立与MS SQL的连接。

The first webApp loads and successfully establishes the connection with MS SQL.

但其余的应用程序无法连接到MS SQL提示:

But the remaining apps fail to connect to MS SQL prompting:

com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:41d72756-1383-427e-8c4f-c3075ae1559a
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2400)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:68)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3132)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$100(SQLServerConnection.java:43)     

注意: Tomcat作为Windows服务运行。并且MSSQL配置为Windows身份验证。

Note: Tomcat runs as windows service. And MSSQL is configured to windows authentication.

编辑:
我知道本机库(DLL)只能加载到JVM一次,因此错误,但我查看网络后仍然没有解决方案。

推荐答案

JDBC驱动程序支持通过integratedSecurity连接字符串属性在Windows操作系统上使用Type 2集成身份验证。要使用集成身份验证,请将 sqljdbc_auth.dll 文件复制到安装JDBC驱动程序的计算机上Windows系统路径上的目录中。

The JDBC driver supports the use of Type 2 integrated authentication on Windows operating systems through the integratedSecurity connection string property. To use integrated authentication, copy the sqljdbc_auth.dll file to a directory on the Windows system path on the computer where the JDBC driver is installed.

或者你可以设置 java.libary.path 系统属性来指定 sqljdbc_auth.dll 。例如,如果JDBC驱动程序安装在默认目录中,则可以在Java应用程序启动时使用以下虚拟机(VM)参数指定DLL的位置:

Alternatively you can set the java.libary.path system property to specify the directory of the sqljdbc_auth.dll. For example, if the JDBC driver is installed in the default directory, you can specify the location of the DLL by using the following virtual machine (VM) argument when the Java application is started:

-Djava.library.path=c:/sqljdbc_<version>/enu/auth/x86

-Djava.library.path=c:/sqljdbc_<version>/enu/auth/x64

请在原始文档中阅读更多信息:
< a href =https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017 =nofollow noreferrer> https:/ /docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017

Please read more about in the original documentation: https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url?view=sql-server-2017

这篇关于SQLException:此驱动程序未配置为集成身份验证tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆