my dog learned polymorphism*
The moose likes JDBC and the fly likes This connection has been closed ERROR!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "This connection has been closed ERROR!!" Watch "This connection has been closed ERROR!!" New topic
Author

This connection has been closed ERROR!!

Eduardo Ponce de Leon
Ranch Hand

Joined: May 13, 2009
Posts: 99
I was creating a class for accesing my DB and designing a query to display some information in my JSP page and as I was testing all of a sudden I am getting an error and all of a suddend i am starting to get this error and I have no idea why..



Can anybody help on this!!
Prabhakar Reddy Bokka
Ranch Hand

Joined: Jul 26, 2005
Posts: 189

Looks like you are trying to create multiple connections in a loop and close them after use. In that order somewhere your code is trying to use closed connection and throwing the exception.
We can see that in the exception log.


SCJP 5, SCWCD 5
Murad Iqbaal
Greenhorn

Joined: Feb 02, 2012
Posts: 9


Was this working before? Once, I also encountered this connection closed error, it was a pain to resolve. Make sure you are not using select * in your query. Pick up table fields by their names and try.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3606
    
  60

Murad Iqbaal wrote:

Was this working before? Once, I also encountered this connection closed error, it was a pain to resolve. Make sure you are not using select * in your query. Pick up table fields by their names and try.

Certainly select * should be avoided, but how could it cause the closed connection error?
Murad Iqbaal
Greenhorn

Joined: Feb 02, 2012
Posts: 9


It was thrown by WebSphere App Server 7.01. It did not make sense that is why it was hard to track. When we changed the select *, it started working.


Also, try deleting and recreating your data source.
Deepak Rao
Ranch Hand

Joined: Jan 24, 2012
Posts: 31

It was thrown by WebSphere App Server 7.01. It did not make sense that is why it was hard to track. When we changed the select *, it started working.

Sometimes when the time out property is set on the connection pool of the application server, it forcibly releases the connection back to the pool after the specified period(ie.whatever is specified in the property,like 300 seconds etc). In which case you get the Connection has been Closed error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This connection has been closed ERROR!!
 
Similar Threads
Logic:iterate
javax.servlet.ServletException: Name java: is not bound in this Context
unable to connect to database
Connecting JSP to MySQL
java.lang.ClassNotFoundException