[英]java.lang.UnsatisfiedLinkError: Native Library sqljdbc_auth.dll already loaded in another classloader
I have multiple applications that needs to connect to MSSQL using windows authentication. 我有多个应用程序需要使用Windows身份验证连接到MSSQL。
The First webApp which is loaded works fine. 加载的第一个webApp工作正常。 but the remaining fail prompting
但剩下的失败提示
Caused by: java.lang.UnsatisfiedLinkError: Native Library $tomcat/bin/sqljdbc_auth.dll already loaded in another classloader
Below is the code used 以下是使用的代码
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connection= DriverManager.getConnection("jdbc:sqlserver://localhost;databaseName=XXX;integratedSecurity=true");
I Have placed sqljdbc*.jar --> tomcat*/lib and sqljdbc_auth.dll --> tomcat*/bin 我已经放置了sqljdbc * .jar - > tomcat * / lib和sqljdbc_auth.dll - > tomcat * / bin
Seems like all my applications are trying to load the shared lib($tomcat/bin/dll) multiple times. 好像我的所有应用程序都试图多次加载共享库($ tomcat / bin / dll)。 Hence the first load works and the remaining fail.
因此第一次加载工作,剩下的失败。
Edit: I understand that the native library (DLL) can only be loaded into the JVM once, hence the error, but I after looking around the net I still have no solution. 编辑:据我所知,本机库(DLL)只能加载到JVM一次,因此出错,但我在环顾网络后仍然没有解决方案。
How can i load the dll only once? 我怎么能只加载一次DLL?
Please Help!! 请帮忙!!
I would guess. 我猜。 That removing the line
删除线
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
would solve the problem. 会解决问题。
As mentioned in the javadoc of DriverManager 正如DriverManager的javadoc中提到的那样
The DriverManager methods
getConnection
andgetDrivers
have been enhanced to support the Java Standard Edition Service Provider mechanism.DriverManager方法
getConnection
和getDrivers
已得到增强,可支持Java Standard Edition Service Provider机制。
......
Applications no longer need to explictly load JDBC drivers usingClass.forName()
.应用程序不再需要使用
Class.forName()
明确加载JDBC驱动程序。
edit This requires a jdbc driver which supports the JDBC 4.0 API. 编辑这需要一个支持JDBC 4.0 API的jdbc驱动程序。 Which should be the case from Microsoft JDBC driver 4.0 on (see: https://docs.microsoft.com/en-us/sql/connect/jdbc/system-requirements-for-the-jdbc-driver )
从Microsoft JDBC驱动程序4.0开始应该是这种情况(参见: https : //docs.microsoft.com/en-us/sql/connect/jdbc/system-requirements-for-the-jdbc-driver )
A matrix which Microsoft JDBC driver supports which SQL server version you can find at https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix Microsoft JDBC驱动程序支持的矩阵,您可以在https://docs.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix找到哪个SQL Server版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.