Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

reason for java.sql.SQLException: Closed Connection

 
Steve Jiang
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code , which works fine normally. We found a exception for "java.sql.SQLException: Closed Connection" in a demo site recently. I don't understand why connection is closed , and what could be the reason.

In demo site, it happens everytime, so it looks like not other thread to close the connection.


Could anyone point me the possible reason for "java.sql.SQLException: Closed Connection" in this case?






2010-09-07 06:44:37,411logp.251 - java.sql.SQLException: Closed Connection
java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:271)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:445)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3127)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3042)
at sysman.util.jdbc.ConnectionWrapper.prepareStatement(ConnectionWrapper.java:577)
at sysman.emo.util.ValueResolver.getCpuCores(ValueResolver.java:805)
 
Sandeep Sanaboyina
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are getting a Closed Connection exception because by line 805, your connection object m_conn is getting closed.

It won't be possible to tell why it is getting closed with the code you have provided.

Instead of using
useThat should stop the application from throwing the exception. But, to find out why the connection is closed, you will have to dig in some more ito your code.

 
Steve Jiang
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. Since the demo site is using shiphome, we can't add the debugger for it. But in development env, we haven't met this case before. That make me very curious how the connection could be closed .



 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone might be closing it. As mentioned, with the code provided, there's no way to know.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic