我在Oracle 11中使用jboss7.0.2 final.目前我面临一个随机发生的问题.但在重负载期间,此错误跟踪会不断增长.试过这么多方法都不会成功.
MyDatasource配置:
<?xml version="1.0" encoding="UTF-8"?>
<datasource jndi-name="sportPool" pool-name="sportPool" enabled="true" jta="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:@10.11.252.200:1521:sportsdb</connection-url>
<driver>oracleDriver</driver>
<pool>
<min-pool-size>1</min-pool-size>
<max-pool-size>75</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>mportal</user-name>
<password>mobile</password>
</security>
<timeout>
<idle-timeout-minutes>60000</idle-timeout-minutes>
</timeout>
</datasource>
堆栈跟踪:
nested exception is java.sql.SQLRecoverableException: Closed Connection
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.translate(SQLExceptionSubclassTranslator.java:82)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:237)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:604)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:638)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:667)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:683)
... 50 more
Caused by: java.sql.SQLRecoverableException: Closed Connection
at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:4051)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3563)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3628)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1493)
at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.executeQuery(CachedPreparedStatement.java:111)
at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:462)
at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:645)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:588)
... 56 more
解决方法:
>查看数据库设置 – 可能的是,数据库中设置的超时短于数据源部署描述符中设置的超时,并且数据库会关闭连接.
>检查您的网络 – 您的防火墙/路由设置可能有问题,并且在路径中间的某处关闭/丢弃连接.
>看一下这个链接JBoss 7 Datasource Configuration.有一种配置数据源描述符的方法,强制JBoss在从池中检出时检查连接.使用valid-connection-checker(更快)或check-valid-connection-sql(更慢)设置并设置
<valid-connection-checker>
org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker
</valid-connection-checker>
要么
<check-valid-connection-sql>
SELECT 1 FROM DUAL
</check-valid-connection-sql>