reason for java.sql.SQLException: Closed Connection [message #474662] |
Tue, 07 September 2010 23:19 |
casttree
Messages: 83 Registered: August 2008
|
Member |
|
|
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?
if (m_conn == null))
return null;
PreparedStatement stmt = null;
ResultSet result = null;
try
{
Line 805: stmt = m_conn.prepareStatement(
"select value from v$osstat where stat_name = 'NUM_CPU_CORES'");
// throw "Closed Connection" exception in this line
result = stmt.executeQuery();
Quote: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)
[Updated on: Wed, 08 September 2010 02:38] by Moderator Report message to a moderator
|
|
|
Re: reason for java.sql.SQLException: Closed Connection [message #474679 is a reply to message #474662] |
Wed, 08 September 2010 02:37 |
|
Michel Cadot
Messages: 68732 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
As the code you posted is not syntaxically valid and as we don't know what you are actually executing, then the answer is: you did something wrong and try to execute something on a closed (or not opened) connection, so open it or don't close it.
Regards
Michel
|
|
|