使用Windows身份验证将我的Sql Server 2008数据库连接到我的Java项目 [英] Connect my Sql Server 2008 database to my Java Project with Windows Authentication

查看:565
本文介绍了使用Windows身份验证将我的Sql Server 2008数据库连接到我的Java项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:我无法将我的Sql Server数据库连接到我的Java项目。我的数据库是SQL Server 2008 R2。并具有Windows身份验证模式。

我使用了以下代码行,但问题仍然存在。

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 =;"

如果我无法使用Windows身份验证进行身份验证,我必须创建第二个数据库相同的数据,唯一的区别是使用Sql Server身份验证而不是Windows身份验证。

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.

推荐答案

JDBC驱动程序支持使用通过integratedSecurity连接字符串属性在Windows操作系统上键入2集成身份验证。要使用集成身份验证,请将sqljdbc_auth.dll文件复制到安装JDBC驱动程序的计算机上Windows系统路径上的目录中。
sqljdbc_auth.dll文件安装在以下位置:

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\

对于Microsoft JDBC支持的任何操作系统SQL Server驱动程序,请参阅使用Kerberos集成身份验证连接到SQL Server,以获取在Microsoft JDBC驱动程序4.0 for SQL Server中添加的功能的说明,该功能允许应用程序使用与Type 4 Kerberos的集成身份验证连接到数据库。

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.

注意:
如果您运行的是32位Java虚拟机(JVM),请使用x86文件夹中的sqljdbc_auth.dll文件,即使操作系统是x64版本。如果在x64处理器上运行64位JVM,请使用x64文件夹中的sqljdbc_auth.dll文件。
或者,您可以设置java.libary.path系统属性以指定sqljdbc_auth.dll的目录。

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.

例如,如果JDBC驱动程序安装在默认目录中,则可以在Java时使用以下虚拟机(VM)参数指定DLL的位置应用程序启动:
-Djava.library.path = C:\ Mysrosoft JDBC Driver 4.0 for SQL

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

这篇关于使用Windows身份验证将我的Sql Server 2008数据库连接到我的Java项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆