Tuesday, March 27, 2012

Can't get IntegratedSecurity with JDBC driver

Hi;

I used SQLServerDatabaseMetaData (which requires a connection to return this data which seems unnecessary) to get:

name: Microsoft SQL Server 2005 JDBC Driver
version: 1.1.1501.101
Passing a url of: jdbc:sqlserver://localhost:1433;DatabaseName=Northwind;IntegratedSecurity=true

I get the error:
Oct 7, 2006 3:46:09 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI <clinit>
WARNING: Failed to load the sqljdbc_auth.dll
Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.

I copied over x86\sqljdbc_auth.dll and then it worked. I assume this is required with the jar file. This leads to a couple of questions:

    What are the files xa\x86\sqljdbc_xa.dll & x64 files for? Are they needed?

    The jar file can just travel with my java code. Should the dll do the same or does it need to be in the path and/or the default directory?

    Are there any other files needed or just these two?

thanks - dave

Take a look at the following msdn link

http://msdn2.microsoft.com/en-us/library/ms378428.aspx

http://msdn2.microsoft.com/en-us/library/ms378672.aspx

Hope this helps

|||

sqljdbc_xa dll is for xa transactions. YOu do not need them if you are not using XA transactions.

The intgrated auth dll is required (sqljdbc_auth.dll) if you are using integrated authentication. See the links raj provided to see where to place this dll.

Those are the only two files outside of the jar.

|||

I am working on the windows authentication on a windows 2003 server. So i used the 64 sqljdbs_auth.dll and rebooted . I still get "WARNING: Failed to load the sqljdbc_auth.dll" and i cannot do a windows authnetication.

I do have the dll in the system pth adn have copied the dll to C:\windows\system32 as well. Any ideas?

thanks!

|||Are you using 64 bits version of windows 2003?|||

Hi, Dave,

Where did you copy the sqljdbc_auth.dll? The directions say to "copy the file to a directory on the Windows system path on the computer where the JDBC driver is installed." The statement confuses me a little. Did you copy the file to a specific location or just any location that happens to be in the path?

Thanks,

Stephanie

|||I copied it to the same directory as the jar file.|||I've copied these dll's all over the file system (including WINNT, system32, and the directory the jar file is in) and I still get WARNING: Failed to load the sqljdbc_auth.dll
Is there a call to the object you can make to get this file to load?

Paul|||The reason I asked about making an object call is because of the error statement I get that reads:
SQLException: This driver is not configured for integrated authentication.

How might I configure it?
My connection string is just
"jdbc:sqlserver://serverName:1433;integratedSecurity=true;"|||

Does the instructions at http://msdn2.microsoft.com/en-us/library/ms378428.aspx help. I'll copy them on this post to relieve some of the confusion. Please pay particular attention to the last suggestion about using the –Djava.library.path explicitly. This will allow you to put the dll in one location on your computer and then point the java executable to it such as:

Java.exe –Djava.libary.path="C:\jdbc\" HelloWorld

In the above example the dll will be in the C:\jdbc\ directory and your application is called HelloWorld.

Connecting with Integrated Authentication

The JDBC driver supports the use of Type 2 integrated authentication on Windows operating systems through the integratedSecurity connection string property. To use integrated authentication, copy the sqljdbc_auth.dll file to a directory on the Windows system path on the computer where the JDBC driver is installed.

The sqljdbc_auth.dll files are installed in the following location:

<installation directory>\sqljdbc_<version>\<language>\auth\

Note: On a 32-bit processor, use the sqljdbc_auth.dll file in the x86 folder. On a 64-bit processor, use the sqljdbc_auth.dll file in the x64 folder.

Alternatively you can set the java.libary.path system property to specify the directory of the sqljdbc_auth.dll. For example, if the JDBC driver is installed in the default directory, you can specify the location of the DLL by using the following virtual machine (VM) argument when the Java application is started:

-Djava.library.path=C:\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_<version>\enu\auth\x86

Regards,

Jaaved Mohammed

|||

Hi,

My sqljdbc.jar is located in the following directory

C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu

And I copied x86 directory from C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.1\enu\auth

And used following steps to establish database connection

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String connectionUrl = "jdbc:sqlserver://localhost:1433;IntegratedSecurity=true;";
Connection con = DriverManager.getConnection(connectionUrl);

and getting the following error

Mar 26, 2007 12:51:50 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI <clinit>
WARNING: Failed to load the sqljdbc_auth.dll
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.loginWithoutFailover(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:193)
at testproject.JdbcDriverTest.main(JdbcDriverTest.java:60)

Please help me out in fixing this issue.

Thanks

Purnima


|||

Purnima,

Did you try the recommendations that I gave above. Did you copy the entire x86 directory to the new location or just the contents of the x86 directory?

Thanks,

Jaaved Mohammed [MSFT]

|||

I copied entire x86 dierctory to the new location.

Thanks

Purnima

|||

hi denial

i am getting same problem and unable to

sort the error

will u please tell me how to sort out this probl,me

where exactle i have to copy sqljdbc_auth.dll.

pleasse replay soon

|||I follow the instruction in connection sample and add the dll path to java command to avoid sqljdbc_auth.dll cannot load error but I got the wrong data. I am using Windows XP SP2 PRO and SQL Server 2005 which is installed in Windows 2003 Server.

connect.java is my filename that i used to test the jdbc connection.
I compiled the connect.java successfully without error but when I run it using java command I got this funny output.

C:\>java -Djava.library.path=C:\Java\tools\sql2005jdbc\sqljdbc_1.2\enu\auth\x86 connect
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20
0E-20

Please help with this error.

No comments:

Post a Comment