Reputation: 61
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:
Global PATH variable Global PATH variable screenshot
C:\Program Files\Java\jdk-13.0.2\bin C:\Program Files\Java\jdk-13.0.2\bin screenshot
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].. ....
Upvotes: 6
Views: 50469
Reputation: 61
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-<version>.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-<version>.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
Upvotes: 5
Reputation: 1
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.
Upvotes: -2
Reputation: 2258
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>
Upvotes: 1
Reputation: 1
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.
Upvotes: -1
Reputation: 165
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.
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.
Unzip it, read install.txt and do as it says
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
Upvotes: 2
Reputation: 489
I had this same problem, and it took me hours to figure out.
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.
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.
Upvotes: 4
Reputation: 951
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.
Upvotes: 5