注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

和申的个人主页

专注于java开发,1985wanggang

 
 
 

日志

 
 

invalid state the connection object is closed  

2009-11-12 10:27:19|  分类: Java |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

java.sql.SQLException: Invalid state, the Connection object is closed.

只在SUN的官方上找到一篇http://forum.java.sun.com/thread.jspa?threadID=678409&start=0&tstart=0

原因,可能是网络不稳定等

用连接池据说可以解决



Author

Invalid state, the Connection object is closed.

Marco Tulio Borges 
Ranch Hand 

Joined: Sep 14, 2004
Posts: 45 
posted Tuesday, November 01, 2005 22:02 private message
Quote
invalid state the connection object is closed - 和申 - 和申的个人主页 Hi there, Ranch folks! I've got a problem and just can't get an answer for that. Here it is:

Tomcat log says:
java.sql.SQLException: Invalid state, the Connection object is closed. 
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.checkOpen(ConnectionJDBC2.java:1305)


My app uses jTDS 1.1SQL Server 2000 (sp3) and Tomcat 5.0.28 with J2SE 1.4.1 and I have a connection pool implementation "made by hand"... Not my own hands BTW. I don't have a clue why the connections are being closed. One thing is for sure: the app doesn't close them. Does anybody have a clue for me?


.: SCJP 1.4 (95%) / SCWCD 1.4 (91%) / SCBCD (77%) :. 
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us." - Calvin
Scott Selikoff 
Saloon Keeper 

Joined: Oct 23, 2005
Posts: 3619 

posted Wednesday, November 02, 2005 03:52 private message
Quote
Did you remember to call rs.next() before reading the first record of the data set? Or is this a non-issue?


My Blog: Down Home Country Coding with Scott Selikoff
Marco Tulio Borges 
Ranch Hand 

Joined: Sep 14, 2004
Posts: 45 
posted Thursday, November 03, 2005 18:54 private message
Quote
Yes, I did... I think the connection is being closed by SQL Server or by my driver (jTDS 1.1) - can the driver do that?

But, what I really want to know is why is this happening so I can try to prevent it. invalid state the connection object is closed - 和申 - 和申的个人主页
Alin Sinpalean 
Greenhorn 

Joined: Jun 02, 2005
Posts: 6 
posted Thursday, November 10, 2005 18:53 private message
Quote
I think the connection is being closed by SQL Server or by my driver (jTDS 1.1) - can the driver do that?


The connection is most likely closed by you (read "your pool implementation") calling close() on it.

There's a very-very slight possibility that there's a communication error between the driver and SQL Server (either network or TDS protocol issue) and that's causing the connection to close, but I wouldn't bet on that. Try without the pool and if it works, then you know where the problem lies.

Alin,
The jTDS Project.
Marco Tulio Borges 
Ranch Hand 

Joined: Sep 14, 2004
Posts: 45 
posted Thursday, November 10, 2005 19:11 private message
Quote
Originally posted by Alin Sinpalean:
The connection is most likely closed by you (read "your pool implementation") calling close() on it.

Hi, Alin! I read it and there's no calling to close() on my code or on the pool implementation.

Originally posted by Alin Sinpalean:
There's a very-very slight possibility that there's a communication error between the driver and SQL Server (either network or TDS protocol issue) and that's causing the connection to close, but I wouldn't bet on that.

I read something about the connection being closed by SQL Server in a forum (or mail list, I don't remember). I'm positive that neither my code (or the pool) is closing the connections (I've searched for close() calls all over it and in a bunch of different ways - with ctrl + alt + h in Eclipse, with search and with the "old-fashion" way: reading class after class).

Originally posted by Alin Sinpalean:
Try without the pool and if it works, then you know where the problem lies.

I've tried but I have other problems related. Creating and closing many connections (not using a pool) brings me performance issues and sometimes (after some time) I get a "Connection refused" (or something like that). 
Don't know what else to do! invalid state the connection object is closed - 和申 - 和申的个人主页 I'm struggling with the DBAs to read the logs from SQL Server... Maybe these logs have a hint for me. Maybe.
[ November 10, 2005: Message edited by: MTulio Borges ]
Prashant Jain 
Greenhorn 

Joined: Aug 19, 2004
Posts: 29 
posted Thursday, November 10, 2005 19:43 private message
Quote
drivers of SQL server can act erratic and there is every possibility that jTDS closes the connection on it's own. I know one thing for sure that MIcrosoft's driver was opeing a lot of implicit connections when I evaluted that one. 

I am assuming that you are not closing the connection any where.If this be the case, If I were you I would try using another open source or data direct's trial version driver. See if this problem still persists. 

ensure that connections are in a commited state. I also faced a sitiuation where by default auto commit was false.After releasing to the pool as well, I didnt achieve much.
Marco Tulio Borges 
Ranch Hand 

Joined: Sep 14, 2004
Posts: 45 
posted Thursday, November 10, 2005 20:16 private message
Quote
Originally posted by Prashant Jain:
drivers of SQL server can act erratic and there is every possibility that jTDS closes the connection on it's own.

Yeah, it's a possibility. But I did not have considered it yet because I haven't seen nobody that uses jTDS with the same problem. I think Alin Sinpaleancould help us with that. Is there any similar cases related at jTDS?
统计信息唧唧歪歪唧唧网ggyygg.net
  评论这张
 
阅读(3286)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016