数据源出现长时间没有使用中断后。出现Could not close JDBC Connection这种问题。

解决方案:
将testOnBorrow设置为true而validationQuery没有设置,或为空,或你给的不是一个select语句且没有数据返回。testOnBorrow也是白设。validationQuery这个的SQL语句一般查询dual表.常用的有SELECT 1 FROM DUA

修改后的tomcat JNDI配置如下:
<?xml version='1.0' encoding='utf-8'?>
<Context allowLinking="true">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/tx" auth="Container" type="javax.sql.DataSource"
  username="xxx"
  password="xxx"
  driverClassName="oracle.jdbc.driver.OracleDriver"
  url="jdbc:oracle:thin:@xxx.xx.xx.xx:1521:xx"
  maxActive="500"
  maxIdle="10"
  maxWait="120000"
  validationQuery="SELECT 1 FROM DUAL"
/>
</Context>