Driver.getConnection 使用 SQLServer 驱动程序和 Java 1.6.0_29 挂起

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7841411/
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-10-30 21:39:21  来源:igfitidea点击:

Driver.getConnection hangs using SQLServer driver and Java 1.6.0_29

javasql-serversql-server-2008jdbc

提问by rpvilao

I didn't know where to write something about this and decided to do it here.

我不知道在哪里写一些关于这个的东西,决定在这里做。

After loooong time debugging my program I could find out that calling Driver.getConnection(string, string, string) hangs the calling thread. Why(?), I really don't know, but I could find out that this happens with java 1.6.0_29 and not with java 1.6.0_26.

经过长时间调试我的程序后,我发现调用 Driver.getConnection(string, string, string) 会挂起调用线程。为什么(?),我真的不知道,但我可以发现这种情况发生在 java 1.6.0_29 而不是 java 1.6.0_26。

Full enviroment:

全环境:

  • OS: Tested on both redhat 6.1 and Windows 2008

  • Driver: MS SQL Server JDBC Driver version 3.0.1301.101

  • Java Versions: 1.6.0_26 and 1.6.0_29

  • 操作系统:在 redhat 6.1 和 Windows 2008 上测试

  • 驱动程序:MS SQL Server JDBC 驱动程序版本 3.0.1301.101

  • Java 版本:1.6.0_26 和 1.6.0_29

As I previously told it works with 1.6.0_26.

正如我之前所说,它适用于 1.6.0_26。

Is there anyone that has any idea what's possibly causing this? Maybe some developer? :p

有没有人知道可能导致这种情况的原因?也许是一些开发人员?:p

Best regards,

最好的祝福,

Rui

采纳答案by Erich Siffert

I encountered exactly the same behaviour:

我遇到了完全相同的行为:

I use both Oracle XE and MS SQL Server Express on my Windows 7 64bit PC - I upgraded to java 1.6.0_29 from 1.6.0_27 (the x64 version) and was surprised to see that the same programs where able to connect to Oracle XE but not to MS SQL Server...

我在 Windows 7 64 位 PC 上同时使用 Oracle XE 和 MS SQL Server Express - 我从 1.6.0_27(x64 版本)升级到 java 1.6.0_29 并且惊讶地看到相同的程序能够连接到 Oracle XE 但不是 MS SQL Server ...

I traced down the problem to javax.sql.DataSource.getConnection()where it was hanging forever - because this is just an interface, the jdbc drivers raised my suspicion...

我将问题追溯到javax.sql.DataSource.getConnection()它永远挂起的地方 - 因为这只是一个接口,jdbc 驱动程序引起了我的怀疑......

I'm using the MS SQL Server JDBC Driver 3.0.1301.202 and I even updated to SQL Server CTP (the "community technical preview") 4.0.1722.1 because my suspicion was that it has to do something with the jdbc driver - but no success: still hanging!

我正在使用 MS SQL Server JDBC 驱动程序 3.0.1301.202,我什至更新到 SQL Server CTP(“社区技术预览”)4.0.1722.1 因为我怀疑它必须对 jdbc 驱动程序做一些事情 - 但没有成功: 还在挂!

My workaround was to downgrade to 1.6.0_27 and -- bang: everything was fine again!

我的解决方法是降级到 1.6.0_27 并且——砰:一切又好起来了!

best regards Erich

最好的问候埃里希

回答by NielsK

Reproduced: Problem occurs with combination of

转载:组合出现问题

  • SQL driver 2.0
  • SQL driver 3.0
  • SQL driver 4.0 CTP 3
  • jTDS SQL Driver 1.2.5

  • SQL server 2008R2

  • Java 1.6.0_29

  • SQL 驱动程序 2.0
  • SQL 驱动程序 3.0
  • SQL 驱动程序 4.0 CTP 3
  • jTDS SQL 驱动程序 1.2.5

  • SQL服务器2008R2

  • Java 1.6.0_29

Change either SQL server version (tested on 2005 & 2008) or Java version (1.6.0_27, 1.7.0_1), and the problem doesn't occur anymore.

更改 SQL 服务器版本(2005 年和 2008 年测试)或 Java 版本(1.6.0_27、1.7.0_1),问题不再出现。

Client / Server OS: Windows 2008R2

客户端/服务器操作系统:Windows 2008R2

Added to the Java Bug Databaseand is being worked on by Oracle.

添加到Java Bug 数据库中,Oracle 正在处理。

Crossposted on Microsoft MSDN Data Access Forum(accepted answer: upgrade to java 7) and Oracle Java JDBC Forums(information that is added here, is also added to the Java Bug Database).

交叉发布在Microsoft MSDN 数据访问论坛(接受的答案:升级到 java 7)和Oracle Java JDBC 论坛(此处添加的信息,也添加到 Java Bug 数据库中)。

回答by Paul

See the solution here https://forums.oracle.com/forums/thread.jspa?messageID=9954398&tstart=0http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/97dce8fd-6487-4bca-80b0-492167db3e0d

请参阅此处的解决方案 https://forums.oracle.com/forums/thread.jspa?messageID=9954398&tstart=0http://social.msdn.microsoft.com/Forums/en/sqldataaccess/thread/97dce8fd-6487-4bca -80b0-492167db3e0d

"Apparently, this is related to SSL use and can be mitigated by replacing the jsse.jar in the jre/lib with that from an earlier version, for instance out of the 1.6.0_27 release. I've been confused by 1.6.0_29 working with MS JDBC and older SQL Server '05 setups which are not doing secure connections. All the newer servers (SQL Server '08 R2) fail as they require SSL and Java 1.6.0_29 does not work using jTDS or MS JDBC in this case."

“显然,这与 SSL 使用有关,可以通过将 jre/lib 中的 jsse.jar 替换为早期版本(例如 1.6.0_27 版本)中的 jsse.jar 来缓解。我对 1.6.0_29 感到困惑使用不进行安全连接的 MS JDBC 和较旧的 SQL Server '05 设置。所有较新的服务器(SQL Server '08 R2)都失败,因为它们需要 SSL 并且 Java 1.6.0_29 在这种情况下无法使用 jTDS 或 MS JDBC .”

回答by Matt Felzani

As an FYI, it appears that there's a new step build #30 in the 1.6 family which fixes the issue: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7103725

作为仅供参考,似乎 1.6 系列中有一个新的步骤构建 #30 可以解决这个问题:http: //bugs.sun.com/bugdatabase/view_bug.do?bug_id=7103725

回答by Michel

Same problem here (SQLJDBC4, MsSQL 2008 R2, JDK1.6.0.29), but after updating to 1.6.0.30problem was solved...

同样的问题(SQLJDBC4,MsSQL 2008 R2,JDK1.6.0.29),但更新到1.6.0.30后问题解决了...

So it should be a critical bug in the DriverManager of 1.6.0.29

所以应该是1.6.0.29的DriverManager中的严重bug

回答by frapontillo

Upgrading to 1.6.0_30 also worked for me. Microsoft has released a statementannouncing the fix in 2012 Q1. It looks like it's a Java vulnerability (BEAST).

升级到 1.6.0_30 也对我有用。Microsoft 已发布声明,宣布在 2012 年第一季度进行修复。看起来这是一个 Java 漏洞(BEAST)。

回答by aandea

I am so happy that I have found this forum. I had the same problem on upgrade (I actually upgraded from 1.6.0_22 to 1.7.1, then downgraded to 1.6.0_29, when the problem has occurred.

我很高兴我找到了这个论坛。我在升级时遇到了同样的问题(我实际上是从 1.6.0_22 升级到 1.7.1,然后在出现问题时降级到 1.6.0_29。

One more thing I have noticed : if I use 1.6.0_29 jre, it fails, but if I use 1.6.0_29 jdk, it works... I spent about a day trying to figure why eclipse (which was using the jre) was failing while myEclipse (which was using the jdk) was working....

我注意到的另一件事:如果我使用 1.6.0_29 jre,它会失败,但是如果我使用 1.6.0_29 jdk,它会起作用......我花了大约一天的时间试图弄清楚为什么 eclipse(使用 jre)是在 myEclipse(使用 jdk)工作时失败....

How can a bug be introduced to such a late release ? (I am in the process of making a java production version recommendation).

怎么会在这么晚的版本中引入错误?(我正在制作java生产版本推荐)。

回答by Debi

I have the same hang problem, and only with java 1.6.0_29. I noticed that if I upgrade to 7.1 the problem goes away

我有同样的挂起问题,只有 java 1.6.0_29。我注意到如果我升级到 7.1 问题就会消失

回答by James Drinkard

I had the exact same issue where jBoss would hang on driver.getConnection(). However, I was using jBoss EAP 5.1, java 1.6.0_37x64, Sql Server 2005, and jtds1.2.5as my jdbc driver.

我遇到了完全相同的问题,jBoss 会挂在 driver.getConnection() 上。但是,我使用 jBoss EAP 5.1、java 1.6.0_37x64、Sql Server 2005 和jtds1.2.5作为我的 jdbc 驱动程序。

The work around I had to use was a jvm setting at startup: -Djsse.enableCBCProtection=false and that resolved it.

我必须使用的解决方法是启动时的 jvm 设置:-Djsse.enableCBCProtection=false 并解决了它。

I don't consider this a fix, but rather a work-around at this point.

我不认为这是一个修复,而是在这一点上的一种解决方法。

I did find a bug: 7105007 : Microsoft & jTDS JDBC driver broken after update to 1.6.0_29that was very similar, but had a different cause. What was interesting was that it showed up on both the MS drivers and jtds drivers.

我确实发现了一个错误:7105007:Microsoft & jTDS JDBC 驱动程序在更新到 1.6.0_29 后损坏,这非常相似,但原因不同。有趣的是,它同时出现在 MS 驱动程序和 jtds 驱动程序上。