• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Invalid state, the Connection object is closed.

 
Marco Tulio Borges
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.1, SQL 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?
 
Scott Selikoff
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you remember to call rs.next() before reading the first record of the data set? Or is this a non-issue?
 
Marco Tulio Borges
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Alin Sinpalean
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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! 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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Sinpalean could help us with that. Is there any similar cases related at jTDS?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic