`
peter.kong
  • 浏览: 57404 次
  • 来自: ...
社区版块
存档分类
最新评论

SQLServerException: DBComms.receive产生的原因

阅读更多


SQLServerException: DBComms.receive产生的原因
Filed under: SQL Server — Jet @ 12:05 am
http://www.javatang.com/archives/2006/04/28/053226.html

使用SQLServer2005的JDBC进行SQL Server2000的操作, 程序中使用了多线程的”Worker Thread”模式, 但是在运行的过程中偶尔会产生这样的SQLServerException:

    使用 DBComms.receive 方法期间发生异常。操作:socket closed。上下文:(9) [Thread[Thread-8,5,main], IO:897a
    9, Dbc:null]。PktNum:0。TotalReceived:0。PktSize:4,096。

后来查了一些有限的资料, 终于知道了原因所在. 原来是因为程序中的代码是非线程安全的, JDBC对象是不能被多个线程共用的. 产生这个异常的原因可能是一个线程中Connection正在关闭或Statement正在被重新执行的时候另一个线程正在使用.

    Hi. I suspect it’s your application code (including the dbcp stuff) that may not be threadsafe. Your JDBC objects can’t be shared by multiple threads. I suspect a connection is being closed, or a statement is being re-executed by one thread while another is still using it.
    Joe Weinstein at BEA Systems

参考资料:
http://www.webservertalk.com/archive135-2006-2-1390423.html

This entry was posted on Friday, April 28th, 2006 at 12:05 am and is filed under SQL Server. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.
分享到:
评论
2 楼 RonQi 2011-02-28  
这么多年过去了,google搜索“DBComms.receive”关键字第一篇文章是你引用的java堂的,第二篇就是你的,呵呵
1 楼 java_code 2008-03-11  
感谢,你的提示.遇到同样的问题.

相关推荐

Global site tag (gtag.js) - Google Analytics