no sqljdbc_auth in java.library.path - java

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

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

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 .

For easy fix follow these steps:
goto: https://learn.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

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]

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.

I had to use windows authentication and I tried every suggested solution out there but with no success till I changed the name of the auth file as follows:
old-name: mssql-jdbc_auth-10.2.0.x64.dll
new-name: sqljdbc_auth.dll
And then it worked!
I looked up for this case to understand it more, apparently for Windows operating systems, the driver looks for sqljdbc_auth.dll by default.
Here is a useful link I've found:
https://learn.microsoft.com/en-us/sql/connect/jdbc/feature-dependencies-of-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver15

To resolve I did the following:
Copied sqljdbc_auth.dll into dir: C:\Windows\System32
Restarted my application

I resolved the issue by:
Upgrading com.microsoft.sqlserver from 6.1.0.jre8 to 10.1.0.jre8-preview:
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>10.1.0.jre8-preview</version>
</dependency>
Adding missing dependency:
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<version>1.3.1</version>
</dependency>
Using the following jdbc connection:
jdbc:sqlserver://;authenticationScheme=NTLM;integratedSecurity=true;domain=;databasename=;encrypt=true;trustServerCertificate=true;user=;password=

Related

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

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]..
....
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.
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.
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
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>
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.
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.

Configure the Application Server can not find the Tomcat place -IntelliJ IDEA

My Tomcat located in the ~/Library/Tomcat9 path.
I can find it by this way:
But when I configure the Application Server using IntelliJ IDEA, I can not find the path, because it is a hidden directory.
Attempt -1
I have tried in my terminal:
defaults write com.apple.finder AppleShowAllFiles -bool true
and restart my Finder.
Attempt -2
Finder Command + F, to set Files visibility.
Refer to Minjun Yu's suggestion, I finally solved this issue by type the path in the Configure:
/Users/luowensheng/Library/Tomcat9

SOLR configuration troule

I am following the tutorial "Running Nutch and Solr on Windows Tutorial" (Part 1) from Youtube and trying to configure properly Solr. I make the change in the C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\solr\WEB-INF\web.xml file as explained in the tutorial - putting the solr home path:
<env-entry-value>C:\cygwin64\home\solr\example\solr</env-entry-value>
And I gain in the browser:
HTTP Status 500 - {msg=SolrCore 'collection1' is not available due to init failure: Error opening new searcher,
trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init
failure: Error opening new searcher at
org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:745) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:307) at ...
When I copy the content of the folder C:\cygwin64\home\solr\example\solr to a new folder at C:\solr and the change the solr path to:
<env-entry-value>C:\solr</env-entry-value>
it works fine. It is the same situation when I Set the Java system property solr.solr.home my Solr Home:Windows > Start > Monitor Tomcat > Java Tab > Java Options -> Enter the following entry:
-Dsolr.solr.home=c:\solr
It works fine in this cae, but not when I put:
-Dsolr.solr.homeC:\cygwin64\home\solr\example\solr
I want solr to work under cygwin as in the tutorial, since it might be needed in that folder later, and I can't get it where could be the problem. Thanks in advance.
I solved the problem, it was about file permissions at Cygwin folder, the Solr coludn't create folders. I changed manually the access rights.

ClassNotFoundException: oracle.jdbc.driver.OracleDriver

I wrote a java servlet program but when i run it, It was showing the Exception java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
My code
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(url, "username", "pass");
I am using Oracle 10.2.0. I added also ojdbc14.jar and ojdbc14_g.jar.
When I give the below command to command line. I get Error: Main method not found in class oracle.jdbc.driver.OracleDriver
I added also ojdbc14.jar and ojdbc14_g.jar
When adding third party libraries to your application, you must be sure they are in the Build Path of your application. In case of web applications, every third party library must be inside the WEB-INF/lib of the application so when deployed to the server (Tomcat, JBoss, etc.) they can be recognized and loaded when running your application.
Steps to rectify (if running from command prompt)
Step 1- Copy the ojdbc6 jar file from
C:\oraclexe\app\oracle\product\11.2.0\server\jdbc\lib (Note- this path may differ as per the installation).
Step 2- Paste the ojdbc6 jar file in the Location
C:\Program Files\Java\jre1.8.0_45\lib\ext (Note- this path may differ as per the installation).
Step 3- Now run the programme java -cp . . It should successfully run without any error.

Why is DB2 Type 4 JDBC Driver looking for native library db2jcct2?

I thought the Type 4 JDBC driver was pure Java and wouldn't require native libraries.
When I put db2jcc4.jar in the WEB-INF/lib directory of my Tomcat app packaged as a .war file, I get the following error when attempting to use the app: Got SQLException: com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.12.55] Failure in loading native library db2jcct2, java.lang.UnsatisfiedLinkError
The relevant application code is as follows and the exception is thrown due to the last line in the listing:
import com.ibm.db2.jcc.DB2SimpleDataSource;
// ...
DB2SimpleDataSource main_db2_data_source = new DB2SimpleDataSource();
main_db2_data_source.setUser(main_database_user);
main_db2_data_source.setPassword(main_database_password);
main_db2_data_source.setServerName(main_database_host);
try {
Integer main_database_port_integer = Integer.parseInt(main_database_port);
main_db2_data_source.setPortNumber(main_database_port_integer);
} catch (NumberFormatException exception) {
throw new WebException("...");
}
Connection main_connection = null;
try {
main_connection = main_db2_data_source.getConnection();
I suspect the problem is that you haven't told it to use the type 4 driver - the same jar file contains both type 4 and type 2 drivers, I believe.
Try:
main_db2_data_source.setDriverType(4);
The db2 driver needs another jar that includes the license.
This license controls the connection type. If you are going to use "db2 connect" to connect to a mainframe as an i series you should use the corresponding license. If you are going to connect to a Linux UNIX or Windows server, the license is included when you get the "Data server client for JDBC"
Also try this:
Goto Configure Build Path --> Libraries
--> JRE System Libraries
--> Native Library Location : Set this to %DB2HOME%/BIN
(which is where db2jcct2.dll is saved)
Recently i have faced this issue, when i was connecting to DB2 from Glassfish server. for this i have followed below steps and resolved this issue.
Please check it the below steps
step1) i have checked DB2 details in Domain.xml file.there i have seen only
username,pwd,databaseName,serverName ,portnumber, But i havent see DriverType.
Means Type of driver is 2 or 4.
2)for adding Type of driver i have logged into the Glassfish server admin console
Resources-->JDBC-->Connection pool -->our poolname --.add extra property
here i haved added as drivertype is 4.
Hence my problem has been solved
Thanks,
Ramaiah Pillala.

Categories