`
zqjshiyingxiong
  • 浏览: 432507 次
  • 性别: Icon_minigender_1
  • 来自: 无锡
社区版块
存档分类
最新评论

error:SQLServer 2000 Driver for JDBC]Broken pipe

    博客分类:
  • JAVA
阅读更多

环境是:linux(red hat) tomcat5.0  java5.0

 

通过single模式(长连接)来操作sqlserver 2000数据库,一直会报:error:SQLServer 2000 Driver for JDBC]Broken pipe。

 

通过网上的情况:

http://topic.csdn.net/u/20080119/11/adb37368-5138-43b7-8624-eb18ec14c75f.html

 

http://forums.java.net/jive/thread.jspa?messageID=272591

 

发现自己的single,getInstance方法没有加synchronized,这里极有可能参数的线程同步的问题。

 

经过测试和实际的应用,还是会出现同样的问题,现在的方式是:

 

每次连接数据时,都将其关闭,下次连接时,重新连接。不使用长连接。

 

Connection conn = null;
try {
    conn = ...;
    Statement stmt = null;
    try {
        stmt = ...;
 
        // Do your thing here
 
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
} finally {
    if (conn != null) {
        conn.close();
    }
}
 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics