0

I have the following problem: I can not connect my Sql Server database to my Java project.My Database is SQL Server 2008 R2. and have the Windows Authentication mode.   I have used the following line of code but still the same problem.

"jdbc: sqlserver :/ / localhost; integratedSecurity = true;"

If a database user have password, I have to integrate with this following line of code?

"jdbc: `sqlserver :/ / localhost; integratedSecurity = true; = user, password =;"

If I can't do the authentication with Windows Authentication, I have to create a second database with the same data, and the only difference is using Sql Server Authentication instead of having Windows Authentication.

6
  • 2
    Did you check the part on integrated security in the documentation? You have to point out java.library.path to where you have the sqljdbc_auth.dll. Commented Jun 28, 2013 at 9:56
  • 1
    Are you able to connect using sql authentication? if so did you check if your windows id is added to the sqlserver logins. Can you also post the error you are getting here Commented Jun 28, 2013 at 10:00
  • I can connect with Sql Authentication, with user and password, but when i change do windows authentication (with the example of the first code line that i insert in the question). Commented Jun 28, 2013 at 10:12
  • 11:16:16,734 WARNING [com.microsoft.sqlserver.jdbc.internals.AuthenticationJNI] (http--0.0.0.0-8999-6) Failed to load the sqljdbc_auth.dll cause :- no sqljdbc_auth in java.library.path Commented Jun 28, 2013 at 10:17
  • 11:16:31,508 ERROR [stderr] (http--0.0.0.0-8999-6) com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. Commented Jun 28, 2013 at 10:18

2 Answers 2

1

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\

For any operating system supported by the Microsoft JDBC Driver for SQL Server, see Using Kerberos Integrated Authentication to Connect to SQL Server for a description of a feature added in Microsoft JDBC Driver 4.0 for SQL Server that allows an application to connect to a database using integrated authentication with Type 4 Kerberos.

Note: If you are running a 32-bit Java Virtual Machine (JVM), use the sqljdbc_auth.dll file in the x86 folder, even if the operating system is the x64 version. If you are running a 64-bit JVM on a x64 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 JDBC Driver 4.0 for SQL

Server\sqljdbc_<version>\enu\auth\x86

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

Sign up to request clarification or add additional context in comments.

Comments

-2

The error you are getting suggests that the issue is with the JDBC driver, not with the database or the application code.

As per the Microsoft forums, the issue is fixed with version 1.2 of the driver. Please try to download this version as it should solve your problem.

The latest version can be found at http://www.microsoft.com/en-in/download/details.aspx?id=11774

Reference: http://www.microsoft.com/en-in/download/details.aspx?id=11774

1 Comment

If put the sqljdbc4.jar in my project lib in Eclipse that solve my problem or i have to install the sqljdbc4.exe into SQL Server 2008?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.