java.sql.SQLException: 关闭连接 java JDBC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24486685/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.sql.SQLException: Closed Connection java JDBC
提问by Ajay Singh Rathore
I am getting the Error in Production as per below. Can any one give some input to eliminate this error.
我收到如下生产错误。任何人都可以提供一些输入来消除此错误。
java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:113)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:147)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:209)
at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:3550)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3396)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3460)
at com.IBS.trade.order.netPortfolio.getClientPortfolioDetails(netPortfolio.java:556)
at core.ClientThreadInteractive.getNetPortFolioData(ClientThreadInteractive.java:14403)
at core.ClientThreadInteractive.netPortfolioSingle(ClientThreadInteractive.java:14370)
at core.ClientThreadInteractive.run(ClientThreadInteractive.java:1895)
回答by Ninad Pingale
Somewhere you are closing connection.
您正在关闭连接的某个地方。
con.close();
And after that trying to access the database.
然后尝试访问数据库。
回答by Ankit Katiyar
Track shows that your connection has been closed when you are trying to use. There are few possibilities depending on your connection management.
当您尝试使用时,Track 显示您的连接已关闭。根据您的连接管理,几乎没有可能性。
1- Your invoked close().
1- 您调用的 close()。
2- You exceed the maximum idle timeout so database has closed your connection.
2- 您超过了最大空闲超时,因此数据库已关闭您的连接。
Basically it depends how you manage your connections if using per thread then may be possible that somewhere it closed during your thread that wasn't working.
基本上,如果使用每个线程,则取决于您如何管理连接,然后可能在您的线程不工作期间关闭了某个地方。
-- Some details about your connection management can explain it better
-- 关于你的连接管理的一些细节可以更好地解释它