no mssql-jdbc_auth-8.2.1.x64 在 java.library.path 中不存在。

huangapple go评论94阅读模式
英文:

no mssql-jdbc_auth-8.2.1.x64 in java.library.path

问题

我正在尝试在我的Maven项目中连接到SQL数据库,但一直收到以下异常:

"com.microsoft.sqlserver.jdbc.SQLServerException: 该驱动程序未配置为集成身份验证... "," ...导致原因:java.lang.UnsatisfiedLinkError:java.library.path中没有mssql-jdbc_auth-8.2.1.x64... "。

我已经尝试了来自https://stackoverflow.com/questions/11707056/no-sqljdbc-auth-in-java-library-path和https://stackoverflow.com/questions/56953643/unsatisfiedlinkerror-no-sqljdbc-auth-in-java-library-path的建议,但对我没有起作用。

我已将sqljdbc_auth.dll的路径放入:

  1. 全局PATH变量 全局PATH变量截图

  2. C:\Program Files\Java\jdk-13.0.2\bin C:\Program Files\Java\jdk-13.0.2\bin截图

  3. pom.xml(作为surefire插件依赖项的配置)
    pom.xml截图

以下是我的代码:

public class JDBC {

    @Test
    public void test() throws SQLException, ClassNotFoundException {

        String UserName = "sa";
        String Password = "Error911";
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String DB_URL = "jdbc:sqlserver://localhost:1433;databaseName=QADB;integratedSecurity=true;";
        // OR by using ip
        // DB_URL = "jdbc:sqlserver://192.168.0.104;databaseName=QADB;integratedSecurity=true;";
        Connection con = DriverManager.getConnection(DB_URL, UserName, Password);
    }
}

控制台输出中的异常:

com.microsoft.sqlserver.jdbc.SQLServerException: 该驱动程序未配置为集成身份验证......
...
导致原因:java.lang.UnsatisfiedLinkError:java.library.path中没有mssql-jdbc_auth-8.2.1.x64:
[C:\Users\Automation\Microsoft JDBC Driver 6.0 for SQL Server\sqljdbc_6.0\enu\auth\x64]...
...
英文:

I'm trying to connect to SQL DB in my Maven project, but keep getting following exception:

"com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ...", "..Caused by: java.lang.UnsatisfiedLinkError: no mssql-jdbc_auth-8.2.1.x64 in java.library.path....".

I've tried out suggestions from https://stackoverflow.com/questions/11707056/no-sqljdbc-auth-in-java-library-path and https://stackoverflow.com/questions/56953643/unsatisfiedlinkerror-no-sqljdbc-auth-in-java-library-path but it didn't work for me.

I've put the path to sqljdbc_auth.dll in:

  1. Global PATH variable Global PATH variable screenshot

  2. C:\Program Files\Java\jdk-13.0.2\bin C:\Program Files\Java\jdk-13.0.2\bin screenshot

  3. pom.xml (as a configuration in surefire plugin dependency)
    pom.xml screenshot

And here is my code:

public class JDBC {

	@Test
	public  void test() throws SQLException, ClassNotFoundException {
		
		String UserName="sa";
		String Password="Error911";
		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
		String DB_URL ="jdbc:sqlserver://localhost:1433;databaseName=QADB;integratedSecurity=true;";
		//OR by using ip
		//DB_URL ="jdbc:sqlserver://192.168.0.104;databaseName=QADB;integratedSecurity=true;";
		Connection con = DriverManager.getConnection(DB_URL, UserName, Password);
	}
}

And the exception in console output:

> com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not
> configured for integrated authentication...........................
>
> ...Caused by: java.lang.UnsatisfiedLinkError: no mssql-jdbc_auth-8.2.1.x64 in java.library.path:
> [C:\Users\Automation\Microsoft JDBC Driver 6.0 for SQL
> Server\sqljdbc_6.0\enu\auth\x64]..
....

答案1

得分: 4

it seems that you don't have the mssql-jdbc_auth-8.2.1.x64 file in your classpath.

As far as I know that file is included in the Microsoft SQL JDBC driver (enu/auth/x64 folder): https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15

You can add that file to your classpath (for example copy it to: C:\Program Files\Java\jdk-13.0.2\bin) and fix the error.

英文:

it seems that you don't have the mssql-jdbc_auth-8.2.1.x64 file in your classpath.

As far as I know that file is included in the Microsoft SQL JDBC driver (enu/auth/x64 folder): https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15

You can add that file to your classpath (for example copy it to: C:\Program Files\Java\jdk-13.0.2\bin) and fix the error.

答案2

得分: 4

我遇到过同样的问题,花了我几个小时才解决。

  1. 确保你复制的是 mssql-jdbc_auth-8.2.1.x64 文件,而不是 sqljdbc_xa.dll 文件,复制到 C:\Program Files\Java\jdk-13.0.2\bin 文件夹中。根据你的 bin 文件夹的截图,我不认为这是问题所在。

  2. 重新启动 Eclipse 并再次运行。我在 Eclipse 运行时将文件复制到 bin 文件夹中,但没有成功。只有在我重新启动 Eclipse 后,驱动程序才开始正常工作。

英文:

I had this same problem, and it took me hours to figure out.

  1. Make sure that you're copying the mssql-jdbc_auth-8.2.1.x64 file and not the sqljdbc_xa.dll file into the C:\Program Files\Java\jdk-13.0.2\bin folder. According to the screenshot of your bin folder, I don't think this is the issue.

  2. Restart Eclipse and run it again. I was copying the file into the bin folder with eclipse running and I had no success. Only after I restarted eclipse did the driver begin to work correctly.

答案3

得分: 2

其他答案中的建议会起作用,但对我来说它们有点误导性。

实际上,你只需要将所需版本的 mssql-jdbc_auth-<version>.x64.dll 放在系统路径上 -> 将其添加到 Path 环境变量 中,以便能够找到此 dll。

您可以通过从以下网址下载与 mssql jdbc 驱动程序相同版本的驱动程序
https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver15#java-and-jdbc-specification-support
然后从 enu\auth\x64\ 文件夹中提取 mssql-jdbc_auth dll。

英文:

The suggestions in other answers will do the trick, but for me they were bit misleading.

Actually all you need to do is put the required version of mssql-jdbc_auth-&lt;version&gt;.x64.dll on system path -> add it to the Path environment variable to be able to find this dll.

You can obtain mssql-jdbc_auth-&lt;version&gt;.x64.dll by downloading the same version of mssql jdbc driver from
https://learn.microsoft.com/en-us/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql-server-ver15#java-and-jdbc-specification-support
and extracting the mssql-jdbc_auth dll from enu\auth\x64\ folder

答案4

得分: 1

只需按照以下步骤操作,就可以解决“java.library.path中没有mssql-jdbc_auth-8.2.1.x64”以及“JDBC SQLServerException:未配置此驱动程序进行集成身份验证”问题。

  1. 根据您的Java版本,从https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15下载sqljdbc_<version>_enu.zip

  2. 解压缩文件,阅读install.txt并按照其中的说明进行操作。

  3. 将位于路径C:/Program Files/Microsoft JDBC DRIVER 8.2 for SQL Server/sqljdbc_/enu/auth/x64中的mssql-jdbc_auth-8.2.2.x64.dll复制到Java/jre8/bin和Java/jre8/lib文件夹中。

英文:

Just follow below steps and it will surely turn out to fix "no mssql-jdbc_auth-8.2.1.x64 in java.library.path" as well as "JDBC SQLServerException: “This driver is not configured for integrated authentication" issue.

  1. Download sqljdbc_&lt;version&gt;_enu.zip from https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15 as per you Java version.

  2. Unzip it, read install.txt and do as it says

  3. Paste mssql-jdbc_auth-8.2.2.x64.dll (present inside path -> C:/Program Files/Microsoft JDBC DRIVER 8.2 for SQL Server/sqljdbc_<version>/enu/auth/x64 to
    Java/jre8/bin and to Java/jre8/lib

答案5

得分: 0

你应该删除Maven依赖项:

然后手动添加JDBC驱动程序jar的依赖 在此处下载

这对我起作用。

英文:

You should delete maven dependency:

&lt;dependency&gt;
&lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
&lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
&lt;/dependency&gt;

Then:
add dependency JDBC driver jar manually download here

This is worked for me.

答案6

得分: 0

为了能够与JDBC建立连接,您需要按以下方式定义连接:

"jdbc:sqlserver://*******;authenticationScheme=NTLM;integratedSecurity=true;domain=******;databasename=**********;encrypt=true;trustServerCertificate=true;user=*******;password=*******;"

使用以下依赖项:

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>10.2.0.jre8</version>
</dependency>
英文:

In order to be able to connect with the JDBC, you need to define the connection as follows:

  &quot;jdbc:sqlserver://*******;authenticationScheme=NTLM;integratedSecurity=true;domain=******;databasename=**********;encrypt=true;trustServerCertificate=true;user=*******;password=*******;&quot;

Use the following dependency:

   &lt;dependency&gt;
    &lt;groupId&gt;com.microsoft.sqlserver&lt;/groupId&gt;
    &lt;artifactId&gt;mssql-jdbc&lt;/artifactId&gt;
    &lt;version&gt;10.2.0.jre8&lt;/version&gt;
   &lt;/dependency&gt;

答案7

得分: -1

我也遇到了同样的问题,我也阅读了你提到的帖子,通过将 mssql-jdbc_auth-8.2.2.x64.dll 添加到<Java 路径>\java\jre\bin\ 而不是 <Java 路径>\java\bin 中,我解决了这个问题。我当时使用的是 JDK 而不是 JRE。

英文:

I also had the same issue, and i also went through the posts that you mentioned, i resolved it by adding the mssql-jdbc_auth-8.2.2.x64.dll in <path to java>\java\jre\bin\ instead of <path to java>\java\bin. I was using a JDK and not a JRE.

huangapple
  • 本文由 发表于 2020年4月9日 16:35:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/61117080.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定