JDBC 驱动程序常见问题解答 (FAQ)Frequently asked questions (FAQ) for JDBC driver

下载下载 JDBC 驱动程序DownloadDownload JDBC Driver

本页是关于 Microsoft JDBC Driver for SQL Server 的常见问题解答。This page provides answers to frequently asked questions about the Microsoft JDBC Driver for SQL Server.

常见问题Frequently asked questions

如何帮助改进 JDBC 驱动程序?How can I help improve the JDBC Driver?
JDBC 驱动程序属于开放源代码,可以在 GitHub 上找到源代码。The JDBC Driver is open-source and the source code can be found on GitHub. 可以通过归档问题和参与基本代码来帮助改进驱动程序。You can help improve the driver by filing issues and contributing to the code base.

驱动程序支持哪些版本的 SQL Server 和 Java?Which versions of SQL Server and Java do the driver support?
有关详细信息,请参阅 Microsoft JDBC Driver for SQL Server 支持矩阵页。See the Microsoft JDBC Driver for SQL Server support matrix page for details.

Microsoft 下载页提供的 JDBC 驱动程序包和 GitHub 提供的 JDBC 驱动程序之间有什么区别? What is the difference between the JDBC driver packages available on the Microsoft download page and the JDBC driver available on GitHub?
Microsoft JDBC Driver 的 GitHub 存储库提供的 JDBC 驱动程序文件是 JDBC 驱动程序的核心,并获得存储库中列出的开放源代码许可证的许可。The JDBC driver files available on the GitHub repository for the Microsoft JDBC driver are the core of the JDBC driver and are under the open-source license listed in the repository. Microsoft 下载页中的驱动程序包包括用于进行 Windows 集成身份验证和通过 JDBC 驱动程序启用 XA 事务的其他库。The driver packages on the Microsoft download page include additional libraries for Windows-integrated authentication and enabling XA transactions with the JDBC driver. 这些其他库获得可下载包随附的许可证的许可。Those additional libraries are under the license included with the downloadable package.

升级驱动程序时,我应该知道什么?What should I know when upgrading my driver?
Microsoft JDBC Driver 9.2 支持 JDBC 4.2 和 4.3(部分)规范,并且安装包中包含以下三个 JAR 类库:The Microsoft JDBC Driver 9.2 supports the JDBC 4.2, and 4.3 (partially) specifications and includes three JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-9.2.0.jre15.jarmssql-jdbc-9.2.0.jre15.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 15.0JDK 15.0
mssql-jdbc-9.2.0.jre11.jarmssql-jdbc-9.2.0.jre11.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 11.0JDK 11.0
mssql-jdbc-9.2.0.jre8.jarmssql-jdbc-9.2.0.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 8.4 支持 JDBC 4.2 和 4.3(部分)规范,并且安装包中包含以下三个 JAR 类库:The Microsoft JDBC Driver 8.4 supports the JDBC 4.2, and 4.3 (partially) specifications and includes three JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-8.4.1.jre14.jarmssql-jdbc-8.4.1.jre14.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 14.0JDK 14.0
mssql-jdbc-8.4.1.jre11.jarmssql-jdbc-8.4.1.jre11.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 11.0JDK 11.0
mssql-jdbc-8.4.1.jre8.jarmssql-jdbc-8.4.1.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 8.2 支持 JDBC 4.2 和 4.3(部分)规范,并且安装包中包含以下三个 JAR 类库:The Microsoft JDBC Driver 8.2 supports the JDBC 4.2, and 4.3 (partially) specifications and includes three JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-8.2.2.jre13.jarmssql-jdbc-8.2.2.jre13.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 13.0JDK 13.0
mssql-jdbc-8.2.2.jre11.jarmssql-jdbc-8.2.2.jre11.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 11.0JDK 11.0
mssql-jdbc-8.2.2.jre8.jarmssql-jdbc-8.2.2.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 7.4 支持 JDBC 4.2 和 4.3(部分)规范,并且其安装包中包含以下三个 JAR 类库:The Microsoft JDBC Driver 7.4 supports the JDBC 4.2, and 4.3 (partially) specifications and includes three JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-7.4.1.jre12.jarmssql-jdbc-7.4.1.jre12.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 12.0JDK 12.0
mssql-jdbc-7.4.1.jre11.jarmssql-jdbc-7.4.1.jre11.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 11.0JDK 11.0
mssql-jdbc-7.4.1.jre8.jarmssql-jdbc-7.4.1.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 7.2 支持 JDBC 4.2 和 4.3(部分)规范,并且其安装包中包含以下两个 JAR 类库:The Microsoft JDBC Driver 7.2 supports the JDBC 4.2, and 4.3 (partially) specifications and includes two JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-7.2.2.jre11.jarmssql-jdbc-7.2.2.jre11.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 11.0JDK 11.0
mssql-jdbc-7.2.2.jre8.jarmssql-jdbc-7.2.2.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 7.0 支持 JDBC 4.2 和 4.3(部分)规范,并且其安装包中包含以下两个 JAR 类库:The Microsoft JDBC Driver 7.0 supports the JDBC 4.2, and 4.3 (partially) specifications and includes two JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-7.0.0.jre10.jarmssql-jdbc-7.0.0.jre10.jar JDBC 4.3(部分)和 4.2JDBC 4.3 (partially), and 4.2 JDK 10.0JDK 10.0
mssql-jdbc-7.0.0.jre8.jarmssql-jdbc-7.0.0.jre8.jar JDBC 4.2JDBC 4.2 JDK 8.0JDK 8.0
     

Microsoft JDBC Driver 6.4 支持 JDBC 4.1、4.2 和 4.3(部分)规范,并且其安装包中包含以下三个 JAR 类库:The Microsoft JDBC Driver 6.4 supports the JDBC 4.1, 4.2, and 4.3 (partially) specifications and includes three JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-6.4.0.jre9.jarmssql-jdbc-6.4.0.jre9.jar JDBC 4.3(部分)、4.2 和 4.1JDBC 4.3 (partially), 4.2, and 4.1 JDK 9.0JDK 9.0
mssql-jdbc-6.4.0.jre8.jarmssql-jdbc-6.4.0.jre8.jar JDBC 4.2 和 4.1JDBC 4.2, and 4.1 JDK 8.0JDK 8.0
mssql-jdbc-6.4.0.jre7.jarmssql-jdbc-6.4.0.jre7.jar JDBC 4.1JDBC 4.1 JDK 7.0JDK 7.0
     

Microsoft JDBC Driver 6.2 支持 JDBC 4.0、4.1 和 4.2 规范,并且其安装包中包含以下两个 JAR 类库:The Microsoft JDBC Driver 6.2 supports the JDBC 4.0, 4.1, and 4.2 specifications and includes two JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
mssql-jdbc-6.2.2.jre8.jarmssql-jdbc-6.2.2.jre8.jar JDBC 4.2、4.1 和 4.0JDBC 4.2, 4.1, and 4.0 JDK 8.0JDK 8.0
mssql-jdbc-6.2.2.jre7.jarmssql-jdbc-6.2.2.jre7.jar JDBC 4.1 和 4.0JDBC 4.1 and 4.0 JDK 7.0JDK 7.0
     

Microsoft JDBC Driver 6.0 for SQL Server 和 Microsoft JDBC Driver 4.2 for SQL Server 支持 JDBC 4.0、4.1 和 4.2 规范,并且其安装包中包含以下两个 JAR 类库:The Microsoft JDBC Drivers 6.0 and 4.2 for SQL Server supports JDBC 4.0, 4.1, and 4.2 specifications and include two JAR class libraries in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
sqljdbc42.jarsqljdbc42.jar JDBC 4.2、4.1 和 4.0JDBC 4.2, 4.1, and 4.0 JDK 8.0JDK 8.0
sqljdbc41.jarsqljdbc41.jar JDBC 4.1 和 4.0JDBC 4.1 and 4.0 JDK 7.0JDK 7.0
     

Microsoft JDBC Driver 4.1 for SQL Server 支持 JDBC 4.0 规范,并且其安装包中包含以下一个 JAR 类库:The Microsoft JDBC Driver 4.1 for SQL Server supports the JDBC 4.0 specification and includes one JAR class library in the installation package as follows:

JARJAR JDBC 规范JDBC Specification 添加版本JDK Version
sqljdbc41.jarsqljdbc41.jar JDBC 4.0JDBC 4.0 JDK 7.0 和 6.0JDK 7.0 and 6.0
     

是否必须在应用程序中更改任何代码,才能结合使用最新驱动程序和我的现有版本 SQL Server?Do I need to make any code changes in my application to use the latest driver with my existing SQL Server version?
一般而言,驱动程序都具有向后兼容性,因此升级驱动程序时,无需更改现有应用程序。In general, the driver is designed to be backward compatible so that you do not need to change your existing applications when upgrading the driver. 如果新的驱动程序版本引入了重大更改,请参阅 JDBC 驱动程序的发行说明部分,了解有关更改的详细信息以及对现有应用程序的影响。In the event that a new driver version introduces a breaking change, the Release Notes for the JDBC Driver section provides clear details on the change and the impact to existing applications. 此外,还可以查看该驱动程序附带的发行说明,了解该版本中已修复的 bug 列表和已知问题。In addition, you can review the release notes included with the driver for a list of bugs fixed in that release and known issues.

驱动程序的费用是多少?How much does the driver cost?
Microsoft SQL Server JDBC 驱动程序是免费提供的,不需要额外付费。The Microsoft JDBC Driver for SQL Server is available at no additional charge.

我能否再分发驱动程序?Can I redistribute the driver?
JDBC 驱动程序 6.0、6.2、6.4 和 7.0 是可再发行的。The JDBC Drivers 6.0, 6.2, 6.4, and 7.0 are redistributable. 查看许可协议中的“可分发代码”子句。Review the "Distributable Code" clause in the license agreements.

我能否使用驱动程序从 Linux 计算机访问 Microsoft SQL Server?Can I use the driver to access Microsoft SQL Server from a Linux computer?
能!Yes! 可以使用该驱动程序从 Linux、Unix 及其他非 Windows 平台访问 SQL Server。You can use the driver to access SQL Server from Linux, Unix, and other non-Windows platforms. 有关详细信息,请参阅 Microsoft JDBC Driver for SQL Server 支持矩阵For more information, see Microsoft JDBC Driver for SQL Server Support Matrix.

驱动程序是否支持 TLS 加密?Does the driver support TLS encryption?
自 1.2 版起,驱动程序支持传输层安全性 (TLS)(以前称为安全套接字层 (SSL))加密。Starting with version 1.2, the driver supports Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL), encryption. 有关详细信息,请参阅使用加密For more information, see Using encryption.

Microsoft JDBC Driver for SQL Server 支持哪些类型的身份验证?Which authentication types are supported by the Microsoft JDBC Driver for SQL Server?
下表列出了可用的身份验证选项。The table below lists available authentication options. 自 4.0 版起,驱动程序支持纯 Java Kerberos 身份验证。A pure Java Kerberos authentication is available starting with the 4.0 release of the driver.

平台Platform 身份验证Authentication
非 WindowsNon-Windows 纯 Java KerberosPure Java Kerberos
非 WindowsNon-Windows SQL ServerSQL Server
非 WindowsNon-Windows Azure Active Directory 身份验证Azure Active Directory Authentication
非 WindowsNon-Windows NTLMNTLM
WindowsWindows 纯 Java KerberosPure Java Kerberos
WindowsWindows SQL ServerSQL Server
WindowsWindows 具有 NTLM 备份的 KerberosKerberos with NTLM backup
WindowsWindows NTLMNTLM
WindowsWindows Azure Active Directory 身份验证Azure Active Directory Authentication
   

驱动程序是否支持 Internet 协议版本 6 (IPv6) 地址?Does the driver support Internet Protocol version 6 (IPv6) addresses?
是的。Yes. 驱动程序支持使用 IPv6 地址。The driver supports the use of IPv6 addresses. 使用连接属性集合和 serverName 连接字符串属性。Use the connection properties collection and the serverName connection string property. 有关详细信息,请参阅生成连接 URLFor more information, see Building the Connection URL.

什么是自适应缓冲?What is adaptive buffering?
自 Microsoft SQL Server 2005 JDBC Driver 1.2 版起,引入了自适应缓冲。Adaptive buffering is introduced starting with Microsoft SQL Server 2005 JDBC Driver version 1.2. 它旨在检索任何种类的大值数据,免去了服务器游标开销。It is designed to retrieve any kind of large-value data without the overhead of server cursors. Microsoft SQL Server JDBC 驱动程序的自适应缓冲功能提供连接字符串属性 responseBuffering,该属性可以设置为“adaptive”或“full”。The adaptive buffering feature of the Microsoft SQL Server JDBC Driver provides a connection string property, responseBuffering, which can be set to "adaptive" or "full". 在 1.2 版中,缓冲模式默认为“full”,应用程序必须显式设置自适应缓冲模式。In the version 1.2 release, the buffering mode is "full" by default and the application must set the adaptive buffering mode explicitly. 从 JDBC 驱动程序 2.0 版起,该驱动程序的默认行为就是“adaptive”。Starting with the JDBC Driver version 2.0, the default behavior of the driver is "adaptive". 因此,应用程序无需显式发出自适应行为请求,即可获取自适应缓冲行为。Thus, your application does not have to request the adaptive behavior explicitly to get the adaptive buffering behavior. 有关详细信息,请参阅使用自适应缓冲什么是自适应响应缓冲以及我为何应使用它?博客文章。For more information, see Using Adaptive Buffering and the blog What is adaptive response buffering and why should I use it?.

驱动程序是否支持连接池?Does the driver support connection pooling?
该驱动程序支持 Java 平台 Enterprise Edition 5 (Java EE 5) 连接池。The driver provides support for Java Platform, Enterprise Edition 5 (Java EE 5) connection pooling. 该驱动程序实现了 JDBC 3.0 所需的接口,从而参与到任何中间件应用程序供应商提供的任何连接池实现中。The driver implements the JDBC 3.0 required interfaces to enable the driver to participate in any connection-pooling implementation that is provided by middleware application server vendors. 该驱动程序将参与这些环境中的已池化连接。The driver participates in pooled connections in these environments. 有关详细信息,请参阅使用连接池For more information, see Using Connection Pooling. 该驱动程序不提供自己的池实现,而是依赖第三方的 Java 应用程序服务器。The driver does not provide its own pooling implementation, but rather it relies on third-party Java application servers.

能否获取驱动程序支持?Is support available for the driver?
该驱动程序提供几种支持选项。Several support options are available. 可以将疑问或问题发布到由 Microsoft 监视的 GitHub 存储库You may post your question or issue to our GitHub repository, which is monitored by Microsoft. 论坛由 Microsoft、MVP 和社区监视。Forums are monitored by Microsoft, MVPs, and the community. 还可以联系 Microsoft 客户支持服务部门。You may also contact Microsoft Customer Support. 开发团队可能会要求你在任何第三方应用程序服务器外重现问题。The development team may ask you to reproduce the issue outside any third-party application servers. 如果无法在托管 Java 容器环境外重现问题,你需要联系相关第三方,这样团队才能继续为你提供帮助。If the issue cannot be reproduced outside the hosting Java container environment, you will need to involve the related third-party so that the team can continue to assist you. 团队可能还会要求你在 Windows 等操作系统上重现问题,以便该问题获得最佳支持。The team may also ask you to reproduce your issue on an operating system such as Windows so the problem can be best supported.

驱动程序是否已经过认证,可用于任何第三方应用程序服务器?Is the driver certified for use with any third-party application servers?
已针对各种应用程序服务器(包括 IBM WebSphere 和 SAP NetWeaver)对该驱动程序进行了测试。The driver has been tested against various application servers including IBM WebSphere and SAP Netweaver.

我如何启用跟踪?How do I enable tracing?
该驱动程序支持使用跟踪(或日志记录)来帮助解决在应用程序中使用 JDBC 驱动程序时遇到的问题。The driver supports the use of tracing (or logging) to help resolve issues and problems with the JDBC Driver when it is used in your application. 为了启用客户端 JAR 跟踪的使用,JDBC 驱动程序将在 java.util.logging 中使用日志记录 API。To enable the use of client-side JAR tracing, the JDBC Driver uses the logging APIs in java.util.logging. 有关详细信息,请参阅跟踪驱动程序操作For more information, see Tracing Driver Operation. 对于客户端 XA 跟踪,请参阅 Data Access Tracing in SQL Server(SQL Server 中的数据访问跟踪)For server-side XA tracing, see Data Access Tracing in SQL Server.

我在哪里可以下载旧版驱动程序,如 SQL Server 2000 JDBC Driver、2005 Driver、1.0、1.1 或 1.2 Driver?Where can I download older versions of the driver such as the SQL Server 2000 JDBC driver, 2005 driver, 1.0, 1.1, or 1.2 driver?
这些驱动程序版本已不再受到支持,因此不能下载。These driver versions are not available for download as they are no longer supported. 我们在不断改善 Java 连接支持。We are continually improving the Java connectivity support. 因此,强烈建议使用最新版 Microsoft JDBC Driver。As such, we highly recommend you work with the latest version of Microsoft JDBC driver.

我使用的是 JRE 1.4。哪个驱动程序与 JRE 1.4 兼容?I am using JRE 1.4. Which driver is compatible with JRE 1.4?
对于使用 SAP 产品且需要 JRE 1.4 支持的客户,可以联系 SAP Service Marketplace 获取 Microsoft JDBC 1.2 驱动程序。For customers who are using SAP products and require JRE 1.4 support, you may contact SAP Service Marketplace to obtain the 1.2 Microsoft JDBC driver.

驱动程序能否使用 FIPS 验证算法进行通信?Can the driver communicate using FIPS validated algorithms?
Microsoft JDBC 驱动程序不包含任何加密算法。The Microsoft JDBC Driver does not contain any cryptographic algorithms. 如果客户使用美国联邦信息处理标准 (FIPS) 认为可接受的操作系统、应用程序和 JVM 算法,并将驱动程序配置为使用这些算法,那么驱动程序仅使用指定的算法进行通信。If a customer leverages operating system, application, and JVM algorithms that are deemed acceptable by Federal Information Processing Standards (FIPS) and configures the driver to use those algorithms then the driver uses only the designated algorithms for communication.

另请参阅See also

JDBC 驱动程序概述Overview of the JDBC driver