jetty服务器java.sql.SQLException: Already closed处理

在jetty的数据源配置中添加如下配置
<Set name="testOnBorrow" type="boolean">true</Set>
<Set name="testOnReturn" type="boolean">true</Set>
<Set name="testWhileIdle" type="boolean">true</Set>
<Set name="validationQuery" type="String">select 1 from dual</Set>

分别是添加了连接池取出,返回,和空闲时是否测试连接的有效性。
其中validationQuery的测试连接有效性的sql配置需要根据数据库进行调整。
最终配置如下:
<New id="ds_my" class="org.apache.commons.dbcp.BasicDataSource">
	<Set name="driverClassName">oracle.jdbc.driver.OracleDriver</Set>
	<Set name="url">jdbc:oracle:thin:@10.0.20.80:1521:dev</Set>
	<Set name="username">ccic</Set>
	<Set name="password">ccic</Set>
	<Set name="maxActive" type="int">100</Set>
	<Set name="maxIdle" type="int">30</Set>
	<Set name="maxWait" type="int">1000</Set>
	<Set name="defaultAutoCommit" type="boolean">true</Set>
	<Set name="removeAbandoned" type="boolean">true</Set>
	<Set name="removeAbandonedTimeout" type="int">60</Set>
	<Set name="logAbandoned" type="boolean">true</Set>
	<Set name="testOnBorrow" type="boolean">true</Set>
        <Set name="testOnReturn" type="boolean">true</Set>
        <Set name="testWhileIdle" type="boolean">true</Set>
        <Set name="validationQuery" type="String">select 1 from dual</Set>
</New>

你可能感兴趣的:(jetty服务器java.sql.SQLException: Already closed处理)