Java ms sql microsoft 的 jdbc 驱动程序和 jTDS 的驱动程序之间的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4393766/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 16:57:15  来源:igfitidea点击:

differences between ms sql microsoft's jdbc drivers and jTDS's driver

javasql-serverjdbcjtds

提问by opensas

What are the differences between each driver? I mean, besides one of them being open-source

每个驱动程序之间有什么区别?我的意思是,除了其中之一是开源的

What are the pros / cons of each one?

每一种的优缺点是什么?

Which one would you recommend?

你会推荐哪一个?



here's jTDS own opinion on the subject: http://jtds.sourceforge.net/

这是 jTDS 自己对这个问题的看法:http://jtds.sourceforge.net/

采纳答案by jzd

They are distinct implementations. The jTDS driver is a type 4 and in my experience has better performance. I have been using the jTDS driver in a production environment without any issues for 5 years.

它们是不同的实现。jTDS 驱动程序是类型 4,根据我的经验,它具有更好的性能。我在生产环境中使用 jTDS 驱动程序已经 5 年没有任何问题了。

I would recommend going with jTDS.

我建议使用 jTDS。

回答by felvhage

One relevant difference is, that the JDBC 4.0 Implementation of the JTDS-Driver (v1.3.1) requires at least Java 7, whereas the JDBC 4.0 Implementation of the Microsoft driver is available in Java 6.

一个相关的区别是,JTDS 驱动程序 (v1.3.1) 的 JDBC 4.0 实现至少需要 Java 7,而 Microsoft 驱动程序的 JDBC 4.0 实现在 Java 6 中可用。

This is important if you want to use Hibernate 4.3 (relying on JDBC 4.0 API) and support Java 6. In that case JTDS is not an option.

如果您想使用 Hibernate 4.3(依赖 JDBC 4.0 API)并支持 Java 6,这很重要。在这种情况下,JTDS 不是一个选项。

回答by Brett Ryan

The key reason FOR using jTDS is that it uses the lesser GPL license where Microsoft's driver uses their own license which has much more restrictions to it. One restriction of note is that you may not

使用 jTDS 的关键原因是它使用较小的 GPL 许可证,而微软的驱动程序使用他们自己的许可证,这对其有更多的限制。需要注意的一个限制是,您不能

  • work around any technical limitations in the software
  • 解决软件中的任何技术限制

There are more restrictions within the license such as:

许可证中有更多限制,例如:

  • transfer the software or this agreement to any third party
  • use the software for commercial software hosting services
  • 将软件或本协议转让给任何第三方
  • 将该软件用于商业软件托管服务

Which could be interpreted that you may not use it in production code, however earlier points in the license seem to allow it.

这可以解释为您可能不会在生产代码中使用它,但是许可证中的较早点似乎允许它。

Having said all of this, I don't know of the licenses within SQL Server itself which may or may not restrict third-party drivers such as jTDS connecting to it.

说了这么多,我不知道 SQL Server 本身的许可证可能会或可能不会限制第三方驱动程序,例如 jTDS 连接到它。

Another point is that jTDS is available via maven, the Microsoft driver is not.

另一点是 jTDS 可通过 maven 获得,而 Microsoft 驱动程序则不是。

<dependency>
    <groupId>net.sourceforge.jtds</groupId
    <artifactId>jtds</artifactId>
    <version>1.3.1</version>
</dependency>

For my choice, use jTDS, it is more permissive and least likely to get you into trouble, and; it's a better driver.

对于我的选择,使用 jTDS,它更宽容,最不可能给您带来麻烦,并且;这是一个更好的驱动程序。

回答by Anil

jTDSperformance is good, but looks like the fail-over property is not supported by jTDS, if the SQL Server switches to secondary, needed to restart the application/server for picking the new ip and reseting the connection.

jTDS 性能不错,但看起来 jTDS 不支持故障转移属性,如果 SQL Server 切换到辅助服务器,则需要重新启动应用程序/服务器以选择新 ip 并重置连接。

回答by Vadzim

While for many years jTDS was much superior than buggy mssql's own driver, the things are changing to the opposite recently.

虽然多年来 jTDS 比有缺陷的 mssql 自己的驱动程序优越得多,但最近情况正在发生相反的变化。

Here is qoute from https://confluence.atlassian.com/bitbucketserver/transitioning-from-jtds-to-microsoft-s-jdbc-driver-776640388.html:

这是来自https://confluence.atlassian.com/bitbucketserver/transitioning-from-jtds-to-microsoft-s-jdbc-driver-776640388.html 的qoute :

Why change drivers?

Recent releases of Hibernate, which Bitbucket Server uses to simplify its persistence layer, have introduced a requirement that the JDBC drivers and connection pools used be JDBC4-compliant. JDBC4 was introduced with Java 6.

The jTDS driver used by releases prior to Bitbucket Server 2.1 is a JDBC3 driver, compatible with Java 1.3, and therefore cannot be used with newer versions of Hibernate. While jTDS 1.3.0 and 1.3.1 claim to implement JDBC4, and JDBC4.1, they actually don't. The new methods have been "implemented", but their implementations are all throw new AbstractMethodError(), which means they can't actually be used. (See an example here, on GitHub.)

Since jTDS 1.3.1 does not provide a functioning JDBC4 implementation, the decision was made to replace jTDS with Microsoft's own SQL Server driver. Microsoft's driver is actively maintained, where jTDS hasn't been updated since 2014 (and prior to the small round of updates done in 2014 it hadn't been updated for multiple years). Microsoft offers a full JDBC4.2 (Java 8) driver and supports all the features of SQL Server, including SQL Server 2016.

为什么要换司机?

Bitbucket Server 用来简化其持久层的最新版本的 Hibernate 引入了一个要求,即所使用的 JDBC 驱动程序和连接池符合 JDBC4。JDBC4 是在 Java 6 中引入的。

Bitbucket Server 2.1 之前的版本使用的 jTDS 驱动程序是 JDBC3 驱动程序,与 Java 1.3 兼容,因此不能与较新版本的 Hibernate 一起使用。虽然 jTDS 1.3.0 和 1.3.1 声称实现了 JDBC4 和 JDBC4.1,但它们实际上并没有。新的方法已经“实现”了,但是它们的实现都是throw new AbstractMethodError(),这意味着它们实际上不能被使用。(参见此处的示例,在 GitHub 上。)

由于 jTDS 1.3.1 不提供有效的 JDBC4 实现,因此决定用 Microsoft 自己的 SQL Server 驱动程序替换 jTDS。Microsoft 的驱动程序得到积极维护,其中 jTDS 自 2014 年以来一直没有更新(在 2014 年进行的小轮更新之前,它已经多年没有更新了)。Microsoft 提供完整的 JDBC4.2 (Java 8) 驱动程序并支持 SQL Server 的所有功能,包括 SQL Server 2016。