how do I call sqljdbc_auth.dll - java

I'm using eclipse and want to make an sql database connection I put the sqljdbc_auth.dll in the buildpath
I'm getting this error message
Dec 18, 2013 10:45:54 AM com.microsoft.sqlserver.jdbc.AuthenticationJNI clinit>
WARNING: Failed to load the sqljdbc_auth.dll cause : no sqljdbc_auth in java.library.path
This driver is not configured for integrated authentication. ClientConnectionId:7a06f...
What am I doing wrong here?

The DLL file has to be present in one of the locations of your PATH environment var.
It may already help to copy the file to the folder windows\system32 or the bin folder of your JRE/JDK. Restart Eclipse and try again.
If this doesn't work you can also specify the parameter java.library.path in your Eclipse Run Configuration like this:
-Djava.library.path=C:\bla\path\where\the\dll\is
Alternativly you can follow this answer which describes in detail how to setup the parameter for a complete project.
See also:
Creating a Java application launch configuration

I solved the problem.
-Djava.library.path=C:\bla\path\where\the\dll\is
just needed quotes around it like this
"-Djava.library.path=C:\Program Files (x86)\jdbc\sqljdbc_4.0\enu\auth\x86"

If the JDBC is still using 32 bit sqljdbc_auth.dll, it could be because the PATH variable has found 64 bit dll before it gets to the newly added PATH environment variable. Add location of the 64 bit sqljdbc_auth.dll in the very beginning of the PATH system variable. In my case it was
C:\nilster\JDBC\sqlserver-sqljdbc_4.2\enu\auth\x64
This helped me get around to the issue.

Related

Where I should place gsdll64.dll in host with windows7 and tomcat7?

I use ghost4j GhostScript to manage TIFF and PDF files in a webapp.
I included Ghost4J into my project using Maven and installed Ghostscript into C:\Program Files\gs\... but after this I still get an error:
java.lang.UnsatisfiedLinkError: Unable to load library 'gsdll64'
To solve this, I must place the file gsdll64.dll in working directory (usually c:\eclipse) as proposed here.
Till here everything fine, but when I deploy the app in the integration environment (win7 and tomcat7) I get this exception:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary.
I installed Ghostscript into C:\Program Files\gs\... in the host and as in this discussion I wrapped code with try {} catch (Exception e) but does not seem to help.
Any idea where I should place the gsdll64.dll or how to solve the error?
One solution is to add dll to %JAVA_HOME%/jre/bin as it is usually on the PATH.
Alternatively add the directory that contains the dll to PATH since on Windows, java.library.path is initialised from the PATH environment variable.
Check this thread on StackOverflow for reference.
For Tomcat 7, can copy gsdll64.dll to %TOMCAT_HOME%\bin directory or create setenv.bat under %TOMCAT_HOME%\bin directory with the following entry.
set PATH=%PATH%;C:\gs\gs9.18\bin
where C:\gs\gs9.18 is the installed Ghostscript folder. Check Apache Tomcat Native Library installation document on this.

PATH and CLASSPATH variables in java

I have just started with jsp. I have downloaded tomcat server. Now when I tried to connect a db with using jdbc. I failed to connect it with MySQL and PostgreSQL. The reasons are:
My java's path is set in PATH variable as C:\Program Files\Java\jdk1.8.0_40\bin
Now for setting path for db (MySQL or PostgreSQL), I am using CLASSPATH variable as E:\XX\XX-XX.jar;
The problem is that when I set classpath my JAVA(not jsp) programs stopped working with an error: Unable to load the class.
and I am also not able to connect yet with any db. Can someone please guide me?
P.S. I am using windows 8.1 and I am not using any IDE.
Could you try adding current directory indicator which is .. Make classpath like E:\XX\XX-XX.jar;.

How to configure Apache Tomcat on a Windows 8.1 installation?

I'm trying to install a 64bit Apache Tomcat distribution on a Windows 8.1 machine but the way in which I have set the environment variables seems to be incorrect.
The steps I have gone through in setting up are as follows:
Copy/Paste apache-tomcat-7.0.57 folder into Program Files (x86)
Set environment variables in the environment variables gui.
Set TOMCAT_HOME to the location of the Tomcat folder: C:\Program Files (x86)\apache-tomcat-7.0.57
Set CATALINA_HOME to the location of the Tomcat folder also: C:\Program Files (x86)\apache-tomcat-7.0.57
But when I execute %TOMCAT_HOME%\bin\startup to check it has been installed correctly I get the following error in my CMD:
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
I found a related question on SO and it gave me the following fix but that http://goo.gl/aNmxGM but that threw another error below:
files was unexpected at this time
I gathered from this that there is a problem in the way I'm setting up the environment variables or possibly the placement of the Tomcat folder. Does anyone have any advice on a fix for this issue?
I think that what you really need is to put it between "" as your path contains space
"%TOMCAT_HOME%\bin\startup"
or
"%TOMCAT_HOME%"\bin\startup
I hope this could help!
Use
"%CATALINA_HOME%"\bin\startup
in the command prompt if you have set the environment variables correctly. I have tried it and it has worked well.

java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library

I have two web-applications which need to run on Tomcat 6, MS SQL 2008 and JTDS-1.2.2 as driver.
If I start only one web application everything is working fine, but as soon as I start the second one I get the following error (it does not matter the order):
java.sql.SQLException: I/O Error: SSO Failed: Native SSPI library
Of course, the library ntlmauth.dll is under C:\WINDOWS\system32
It seems that the second application which starts is not able to find the ntlmauth.dll for the single sign on.
I got past this by changing the url from
jdbc:jtds:sqlserver://host_server:1433/Database_name
to
jdbc:jtds:sqlserver://host_server:1433/Database_name;user=XXX;password=YYY
Apparently, "When URL [does] not contains user and password properties, systems uses Windows authentication method, and "SSPI Native library not found" error appears."
This is the solution:
Download the jTDS driver, unzip it, and copy x86\SSO\ntlmauth.dll to jdk\jre\bin.
This should solve your issue.
Edit:
Without the JDK installed the path for me was C:\Program Files\Java\jre7\bin\ntlmauth.dll
jTDS must be able to load the native SPPI library (ntlmauth.dll). Place this DLL anywhere in the system path (defined by the PATH system variable) and you're all set.
If you are trying to run two (or more) Tomcat applications on the same server that both access a SQL Server using the JTDS driver and windows authentication, a very helpful answer courtesy of Chris White is here.
Chris' answer has to do with sqljdbc_auth.dll, but the recommendations are the same for the JTDS driver and ntlmauth.dll:
Put ntlmauth.dll into the tomcat 7.0\bin directory. Actually, I believe you can put ntlmauth.dll into any directory in the system path, or the Java jre\bin directory.
Importantly, don't bundle the JTDS jar in the war file of any Tomcat application using the JTDS driver. Instead, put one copy in the Tomcat\lib directory, where Tomcat will load it and make it available to all apps.
If you are on 64-bit windows but running 32-bit java (the one in program files x86) then you need the 32-bit ntlmauth dll and not the 64 bit one that you might have expected.

'javac' cannot be found problem

I have a Java application hosted on a remote tomcat instance that executes a bat file which contains the following line
javac filename.java
I receive the following error :-
'javac' is not recognized as an
internal or external command, operable
program or batch file.
I have set the path in the environmental variables. I tried running the same bat file on the machine, it works(which means there is nothing wrong with the path). But running it through the application gives the error. What might be the problem?
Setting the correct path in your environment does not fix the path in the environment of the running tomcat process. If you changed the path in the system settings, a tomcat restart (or system reboot) probably solves your problem.
Once you add %JAVA_HOME%\bin to the PATH var on the remote machine (assuming you have %JAVA_HOME% set there), you will need to run up a new cmd window for the new PATH to be available.
You should set the classpath for the user who is executing tomcat, not only for your login user.
If you have the JRE installed, and not the JDK, you'd be able to run Tomcat but there wouldn't be a javac.exe. Go to JAVA_HOME/bin and see if there's a javac.exe. If not, you have the JRE installed, and you'll have to go get the JDK.
Just curious - why is your Tomcat app calling javac.exe? Are you creating classes on the fly? If yes, why would you not be generating byte code using ASM instead?

Categories

Resources