我们在tomcat上运行了一个带有MySQL后端的webapp.一切都很好,然后突然我们开始得到这个异常java.sql.sqlException:已经关闭.
整个堆栈跟踪是:
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] Fetching JDBC Connection from DataSource
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] Returning JDBC Connection to DataSource
DEBUG [org.springframework.jdbc.datasource.DataSourceUtils] Could not close JDBC Connection
java.sql.sqlException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:114)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:191)
at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:333)
at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:294)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:405)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:428)
at com.nokia.analytics.aws.aggregate.service.importer.DBInsert.truncateTable(DBInsert.java:135)
at com.blah.analytics.aggregate.service.importer.AggregateCollector.pullAndInsert(AggregateCollector.java:85)
at com.blah.analytics.aggregate.service.importer.AggregateCollector.call(AggregateCollector.java:96)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:679)
我们使用org.apache.commons.dbcp.BasicDataSource作为我们的数据源.我搜索了不少但无济于事.
它不会总是发生,因此很难再现.这似乎是db连接池的问题.有人建议将this参数设为负值.目前我们没有更改这些参数(都具有默认值).
我们应该采取什么方法来避免它?
编辑:
相关代码在(DBInsert.java)中
133:String sql =“DELETE FROM”tableName;
134:logger.debug(sql);
135:this.jdbcTemplate.execute(sql);
(133-135是行号,在例外中指定)
我的数据源配置:
MysqL.jdbc.Driver" />
最佳答案
原文链接:https://www.f2er.com/spring/432021.html