ms sql microsoft jdbc 驱动程序和 jTDS 驱动程序之间的差异

发布于 2024-10-06 13:57:23 字数 184 浏览 5 评论 0原文

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

每一种的优点/缺点是什么?

您会推荐哪一款?


以下是 jTDS 自己对此主题的看法:http://jtds.sourceforge.net/

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/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

颜漓半夏 2024-10-13 13:57:23

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

我建议使用 jTDS。

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.

I would recommend going with jTDS.

决绝 2024-10-13 13:57:23

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

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

为什么要更换驱动程序?

Hibernate 的最新版本,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,他们实际上没有。新方法
已经“实现”了,但是它们的实现都是抛出新的
AbstractMethodError(),这意味着它们实际上无法使用。 (看
示例此处,在 GitHub 上。)

由于 jTDS 1.3.1 不提供有效的 JDBC4 实现,
决定用 Microsoft 自己的 SQL Server 替换 jTDS
司机。 Microsoft 的驱动程序得到了积极维护,而 jTDS 则没有
自 2014 年以来已更新(并且在完成小轮更新之前)
2014 年,它已经多年没有更新了)。微软提供了一个
完整的 JDBC4.2 (Java 8) 驱动程序并支持 SQL 的所有功能
服务器,包括 SQL Server 2016。

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

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

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.

晨敛清荷 2024-10-13 13:57:23

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

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

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.

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.

初见你 2024-10-13 13:57:23

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

  • 解决软件中的任何技术限制

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

  • 将软件或本协议转让给任何第三方
  • 将该软件用于商业软件托管服务

这可能会被解释为您不得在生产代码中使用它,但许可证中的早期点似乎允许这样做。

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

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

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

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

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

  • 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.

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

<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.

云淡月浅 2024-10-13 13:57:23

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

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.

梅窗月明清似水 2024-10-13 13:57:23

jTDS 1.3.1(最新发布的版本)存在 TLS 问题,这对某些人来说可能会改变游戏规则。问题可能是从 Java 8 开始的 - 我看到了这样的评论 - 但尚未得到验证。有一个“私人”未发布的修复程序 - 请参阅例如 https://community.microfocus.com/cyberres/idm/w/identity_mgr_tips/19661/enforcing-ssl-tlsv1-2-jdbc-connection-via-jtds- jdbc 驱动程序
这对我有用。
您可以在下面找到尝试使用原始 jTDS 1.3.1 和 TLS 连接到 MS SQL 时生成的异常:

java.sql.SQLException: Network error IOException: Connection reset
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at jtds.JtdsMain.getData(JtdsMain.java:30)
    at jtds.JtdsMain.start(JtdsMain.java:15)
    at jtds.JtdsMain.main(JtdsMain.java:9)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.readFully(TdsTlsInputStream.java:131)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.primeBuffer(TdsTlsInputStream.java:100)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.read(TdsTlsInputStream.java:78)
    at sun.security.ssl.InputRecord.readFully(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at net.sourceforge.jtds.ssl.SocketFactories$TdsTlsSocketFactory.createSocket(SocketFactories.java:101)
    at net.sourceforge.jtds.jdbc.SharedSocket.enableEncryption(SharedSocket.java:330)
    at net.sourceforge.jtds.jdbc.TdsCore.negotiateSSL(TdsCore.java:577)
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:365)
    ... 6 more

jTDS 1.3.1 (the latest released version) has problem with the TLS, what can be a game-changer for some people. The problems might have started with Java 8 - I saw such comment - but it's not verified. There's a "private", not released fix - see e.g. https://community.microfocus.com/cyberres/idm/w/identity_mgr_tips/19661/enforcing-ssl-tlsv1-2-jdbc-connection-via-jtds-jdbc-driver
It worked for me.
Below you can find an exception generated while trying to connect to the MS SQL using the original jTDS 1.3.1 and TLS:

java.sql.SQLException: Network error IOException: Connection reset
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:436)
    at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at jtds.JtdsMain.getData(JtdsMain.java:30)
    at jtds.JtdsMain.start(JtdsMain.java:15)
    at jtds.JtdsMain.main(JtdsMain.java:9)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.readFully(TdsTlsInputStream.java:131)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.primeBuffer(TdsTlsInputStream.java:100)
    at net.sourceforge.jtds.ssl.TdsTlsInputStream.read(TdsTlsInputStream.java:78)
    at sun.security.ssl.InputRecord.readFully(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
    at net.sourceforge.jtds.ssl.SocketFactories$TdsTlsSocketFactory.createSocket(SocketFactories.java:101)
    at net.sourceforge.jtds.jdbc.SharedSocket.enableEncryption(SharedSocket.java:330)
    at net.sourceforge.jtds.jdbc.TdsCore.negotiateSSL(TdsCore.java:577)
    at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:365)
    ... 6 more
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文