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

SQLServerException: DBComms.receive产生的原因

阅读更多
SQLServerException: DBComms.receive产生的原因

原文:http://www.javatang.com/archives/2006/04/28/053226.html

Filed under: SQL Server — Jet @ 12:05 am

使用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
分享到:
评论
1 楼 xiaoyuqi00 2009-08-04  
请问这个问题怎么解决啊?

相关推荐

Global site tag (gtag.js) - Google Analytics