4

Java Connecting with MicrosoftSqlServer 2005.

  • IDE Used: Eclipse helios
  • Driver used: sqljdbc.jar
  • .dll used: sqljdbc_auth.dll from x86 folder.
  • .dll is added to system32 folder rebooted system.
  • Ping succeeded connecting eclipse with SQL server 2005 using sqljdbc.jar

Error report is:

15:45:48,218 ERROR [STDERR] Jan 28, 2011 3:45:48 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI <clinit>
WARNING: Failed to load the sqljdbc_auth.dll
15:46:02,671 ERROR [STDERR] com.microsoft.sqlserver.jdbc.SQLServerException: The TCP/IP connection to the host localhost, port 1433 has failed. Error: "connect timed out. Verify the connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port.".

HELLO ALL,

I HAVE EXECUTED THIS IN COMMAND PROMPT: I'M GETTING THIS ERROR NOW:

C:\>java -cp .;"C:\sqljdbc_1.2\enu\sqljdbc.jar" -Djava.library.path="C:\sqljdbc_
1.2\enu\auth\x86" mfirst
Exception in thread "main" java.lang.NoClassDefFoundError: mfirst
Caused by: java.lang.ClassNotFoundException: mfirst
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: mfirst.  Program will exit.
pnuts
  • 58,317
  • 11
  • 87
  • 139
srikanth
  • 71
  • 1
  • 2
  • 4
  • verify this: "connection properties, check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port, and that no firewall is blocking TCP connections to the port." – Harry Joy Jan 28 '11 at 10:34
  • put this sqljdbc.jar file into C:\Program Files\Java\jdk1.6.0_21\jre\lib\ext ... And use sqljdbc4.jar for this sql server connection. And you may not be allow to connecting to sql .. means that server – Ravi Parmar Jan 28 '11 at 10:36
  • com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. – srikanth Jan 28 '11 at 10:38
  • com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. NOW I'M GETTING THIS ERROR – srikanth Jan 28 '11 at 10:38
  • This generally indicates that the driver can not find the appropriate sqljdbc_auth.dll in the JVM library path. To correct the problem, please use the java.exe -D option to specify the "java.library.path" system property value. You will want to specify the full path to the directory contain the sqljdbc_auth.dll. For example: java -cp .;"c:\jdbcv1_2\sqljdbc.jar" -Djava.library.path="c:\jdbcv1_2\auth\x86" myApp Alternatively, you can copy the sqljdbc_auth.dll to a directory in the search path (example: the local directory where you are executing your application). – Harry Joy Jan 28 '11 at 10:42
  • thanks for the reply... but where to add those lines in environment variables or in cmd prompt? i'm developing a web project its in d:\xyz\mno\ directory – srikanth Jan 28 '11 at 10:45
  • I DINT UNDERSTOOD HOW TO DO THIS PLZ HELP:For example: java -cp .;"c:\jdbcv1_2\sqljdbc.jar" -Djava.library.path="c:\jdbcv1_2\auth\x86" myApp – srikanth Jan 28 '11 at 10:49
  • if you dont get it worked then try second option. – Harry Joy Jan 28 '11 at 10:51
  • Hi Joy, I even copied it in the application folder. I even executed it in command prompt i'm getting the error as above(IN QUESTION) – srikanth Jan 28 '11 at 10:57
  • 16:29:45,468 ERROR [STDERR] com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. – srikanth Jan 28 '11 at 11:01
  • You may also get the same error message if the application is trying to use the incorrect architecture (x86 VS x64) version of the sqljdbc_auth.dll. Try specifying the directory path to the other architecture. If you are on a x64 machine running x64 OS, but the JVM you are using is the x86 version, you will need to specify and use the x86 version of the sqljdbc_auth.dll. – Harry Joy Jan 28 '11 at 11:12

3 Answers3

4

Harry is right. The driver can't load the authentication DLL. Go to your environment variables and add to your PATH the value C:\JavaLib\Microsoft SQL Server JDBC Driver 3.0\sqljdbc_3.0\enu\auth\x64 (choose the correct auth subfolder for your machine - i.e. x86 etc) restart your IDE and it should work as advertised

taskinoor
  • 45,586
  • 12
  • 116
  • 142
Matt
  • 41
  • 2
3

Please copy sqljdbc_auth.dll file in to jdk bin folder. i.e.C:\Program Files\Java\jdk1.6_32\bin paste file in your server side where JVM is running if consuming web services please apply same in client side as well.

cfg.xml
  • 51
  • 4
0

Your program output doesn't look like the problem is anything to do with JDBC. You're invoking Java, passing it some environment arguments, but fundamentally telling it to start execution with the class mfirst.

And accordingly, the program output states:

Could not find the main class: mfirst. Program will exit.

This doesn't look like a proper name for the main class (no package, no uppercase characters). Are you sure you're invoking the program correctly?

Andrzej Doyle
  • 102,507
  • 33
  • 189
  • 228