no sqljdbc_auth in java.library.path
Solution 1
1) Download the JDBC Driver here.
2) unzip the file and go to sqljdbc_version\fra\auth\x86 or \x64
3) copy the sqljdbc_auth.dll to C:\Program Files\Java\jre_Version\bin
4) Finally restart eclipse
Solution 2
Here are the steps if you want to do this from Eclipse :
1) Create a folder 'sqlauth' in your C: drive, and copy the dll file sqljdbc_auth.dll to the folder
1) Go to Run> Run Configurations
2) Choose the 'Arguments' tab for your class
3) Add the below code in VM arguments:
-Djava.library.path="C:\\sqlauth"
4) Hit 'Apply' and click 'Run'
Feel free to try other methods .
Solution 3
For easy fix follow these steps:
- goto: https://docs.microsoft.com/en-us/sql/connect/jdbc/building-the-connection-url#Connectingintegrated
- Download the JDBC file and extract to your preferred location
- open the auth folder matching your OS x64 or x86
- copy sqljdbc_auth.dll file
- paste in: C:\Program Files\Java\jdk_version\bin
- restart either eclipse or netbeans
Solution 4
The error is clear, isn't it?
You've not added the path where sqljdbc_auth.dll is present. Find out in the system where the DLL is and add that to your classpath.
And if that also doesn't work, add the folder where the DLL is present (I'm assuming \Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x86) to your PATH variable.
Again if you're going via ant or cmd you have to explicitly mention the path using -Djava.library.path=[path to MS_SQL_AUTH_DLL]
Solution 5
I've just encountered the same problem but within my own application. I didn't like the solution with copying the dll since it's not very convenient so I did some research and came up with the following programmatic solution.
Basically, before doing any connections to SQL server, you have to add the sqljdbc_auth.dll
to path.. which is easy to say:
PathHelper.appendToPath("C:\\sqljdbc_6.2\\enu\\auth\\x64");
once you know how to do it:
import java.lang.reflect.Field;
public class PathHelper {
public static void appendToPath(String dir){
String path = System.getProperty("java.library.path");
path = dir + ";" + path;
System.setProperty("java.library.path", path);
try {
final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths");
sysPathsField.setAccessible(true);
sysPathsField.set(null, null);
}
catch (Exception ex){
throw new RuntimeException(ex);
}
}
}
Now integration authentication works like a charm :).
Credits to https://stackoverflow.com/a/21730111/1734640 for letting me figure this out.
AFF
Updated on July 14, 2022Comments
-
AFF almost 2 years
I have a Java EE Web Application which connects to a SQL Server 2008 instance. I don't have any problem connecting and retrieving to all my tables, except for one of them. The error in the Tomcat log is:
WARNING: Failed to load the sqljdbc_auth.dll cause :- no sqljdbc_auth in java.library.path
-
AFF almost 12 yearsThe problem is here: I have searched internet, the response was like your response but I DON'T HAVE THIS DLL FILE IN MY COMPUTER!!!!
-
afrin216 almost 12 yearsWell then we have a problem, rite? I think you haven't installed the driver at all! Go to this link - msdn.microsoft.com/en-us/library/ms378428%28v=sql.90%29.aspx . They give step by step on how to install and use
-
Maurício over 10 years@andrewrjones The JDBC driver does. However, it cannot connect using a Trusted Connection without this DLL. You can do a username/password connection - just not a trusted connection.
-
abarisone about 8 yearsCould you please add a little more description to the solution you provide?
-
dance2die about 6 years@AmineSoumiaa I believe that it should go under bin under JDK not under JRE. I just tried.
-
vkrams almost 6 yearsPerfect answer... easy method. Thanks @AmineSoumiaa
-
Dima Fomin about 5 yearsFor me adding to CLASSPATH was not enough, had to add to Path too
-
Matt Felzani almost 4 yearsgreat option here leveraging the
java.library.path
argument. saved me a ton of headache as the users can't copy/paste to theC:\Program Files
folder. thanks! -
wilmol about 3 yearsIt's not clear at all. I add maven dependency, it should be there, why do I have to manually download and install it?
-
Adam Gripton over 2 yearsOh my goodness thank you so much. I was driving myself mad going through dozens of different approaches that don't work.
-
gunescelil almost 2 yearswhy do we need to add something to our java\bin folder? Is not there any other method only we import via gradle and maven?