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

查看:48
本文介绍了使用 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 操作系统上使用Type 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 Driver for SQL Server 支持的任何操作系统,请参阅使用 Kerberos 集成身份验证连接到 SQL Server,以了解 Microsoft JDBC Driver 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:Microsoft 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

服务器sqljdbc_<版本>enuauthx86

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

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

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