septerr
septerr

Reputation: 6603

JDBC / IntelliJ Failed to load the sqljdbc_auth.dll

I am trying to run a small test program in IntelliJ. Code:

String driverClass = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    String url = "jdbc:sqlserver://test.test.com;integratedSecurity=true";
    String userName = "test";
    String password = "test";
    Class.forName(driverClass);
    try (Connection con = DriverManager.getConnection(url, userName, password);
         Statement st1 = con.createStatement();
         Statement st2 = con.createStatement();
    ) {
      String sql1 = "EXEC  [dbo].[Cleanup]";
      String sql2 = "EXEC  [dbo].[DetailsALL] \"DetailsALL.csv\" ";
      st1.execute(sql1);
      st2.execute(sql2);

    }catch(Exception e){
     System.out.println(e.getMessage());
    }

I have added following to the VM options:

-Djava.library.path="\Users\sgupta\IdeaProjects\todos\sqljdbc_4.0\enu\auth\x86\" enter image description here

Running the program results in:

Apr 05, 2013 5:43:20 PM com.microsoft.sqlserver.jdbc.AuthenticationJNI 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:db8a3aa3-d84b-49d2-a7eb-64c4187a8303

i have double checked the path I have specified in the VM option. Any other suggestions? Thanks.

Upvotes: 3

Views: 6200

Answers (1)

Rob.Kachmar
Rob.Kachmar

Reputation: 2188

It looks like I have some bad news for you. This is straight from the sqljdbc documentation that is included with the .tar.gz file. After you upack the file, go to this help webpage: sqljdbc_4.0/enu/help/default.htm

Under Contents >>> Connecting to SQL Server with the JDBC Driver >>> Building the Connection URL, go to the section: "Connecting with Integrated Authentication"

At the bottom of this section is has the following quote, which basically says you can't use the dll approach for non-windows systems.

The JDBC driver does not support the integrated authentication when the driver runs on non-Windows operating systems. The driver also does not provide any functionality to supply Windows Authentication credentials, such as user name and password, when connecting to SQL Server from non-Windows operating systems. In such cases, the applications must use SQL Server Authentication instead.

However, this same help file's equivalent msdn documentation seems to suggest that for all non-windows operating systems, you can get it to work with Kerberos. http://msdn.microsoft.com/en-us/library/ms378428.aspx

This msdn link gives an overview of the the Kerberos process, but it falls short on a detailed setup for non-windows machines. http://msdn.microsoft.com/en-us/library/gg558122.aspx

If anyone has figured out the details for getting Kerberos working to connect to SQL Server from a non-windows machine, I'd love to hear from them.

Upvotes: 8

Related Questions