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

nsc4cvqm  于 2023-02-28  发布在  Java
关注(0)|答案(6)|浏览(340)

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 no sqljdbc_auth in java.library.path and 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].. ....

yv5phkfx

yv5phkfx1#

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.

aiazj4mn

aiazj4mn2#

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.
5n0oy7gb

5n0oy7gb3#

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_<version>_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_/enu/auth/x64 to Java/jre8/bin and to Java/jre8/lib
mqxuamgl

mqxuamgl4#

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

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

Use the following dependency:

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

bttbmeg05#

You should delete maven dependency:

<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>

Then: add dependency JDBC driver jar manually download here

This is worked for me.

ut6juiuv

ut6juiuv6#

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 \java\jre\bin\ instead of \java\bin. I was using a JDK and not a JRE.

相关问题