使用Spring的SQL服务器连接问题
我发现使用 JDBC 或 Spring 将 Web 应用程序连接到 SQL Server 数据库(不是 Express)时出现问题。
在我的代码的某个时刻,我调用:
this.conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
并且应用程序正在正确运行,但是它正在等待并且不会继续。另一个 Web 应用程序也会发生同样的情况:
getJdbcTemplate().query(...)
如果我使用以下命令查看数据库:
SELECT SPID, STATUS, PROGRAM_NAME, LOGINAME=RTRIM(LOGINAME), HOSTNAME, CMD
FROM MASTER.DBO.SYSPROCESSES
WHERE DB_NAME(DBID) = 'myDB' AND DBID != 0
我可以看到有一个连接打开,但“正在等待命令”。没有处理任何异常,它只是在等待某些事情。
该连接的 SQL Server Profiler(审核登录)返回:
-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
直到几周前它才工作。我认为这应该与SQLServer配置有关,但我很确定我没有改变任何东西。我们可以排除防火墙问题,因为连接已正确创建。有人可以帮助我吗?
I found an issue connecting my web application using JDBC or Spring to a SQL Server database (not Express).
At some point of my code I call:
this.conn = DriverManager.getConnection(db_connect_string, db_userid, db_password);
and the application is running correctly but, it's waiting and doesn't proceed. The same happens with another web application with:
getJdbcTemplate().query(...)
If I take a look to the db using:
SELECT SPID, STATUS, PROGRAM_NAME, LOGINAME=RTRIM(LOGINAME), HOSTNAME, CMD
FROM MASTER.DBO.SYSPROCESSES
WHERE DB_NAME(DBID) = 'myDB' AND DBID != 0
I can see there is a connection opened but "AWAITING COMMAND". No exception is handled, it's just waiting for something.
The SQL Server Profiler for that connection (Audit login) returns:
-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
It works until some weeks ago. I think it should be something related to SQLServer configuration, but I'm quite sure I didn't change anything. We can exclude a firewall issue because the connection is correctly created. Anyone could help me, please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Mark Rotteveel 所建议的,这是一个 Java 1.6.0_29 错误。
As suggested by Mark Rotteveel it's a Java 1.6.0_29 bug.