我创建了一个连接缓存池,偶尔会收到Invalid stale connection object
错误。当我刷新页面并执行相同的操作时,它工作正常,意味着异常消失。
这是我的连接池配置,
<bean id="myDataSource" class="oracle.jdbc.pool.OracleDataSource"
destroy-method="close">
<property name="connectionCachingEnabled" value="true" />
<property name="URL" value="${jdbcUrl-myapp}" />
<property name="user" value="${jdbcUsername-myapp}" />
<property name="password" value="${jdbcPassword-myapp}" />
<property name="connectionProperties">
<value>
oracle.jdbc.timezoneAsRegion=false
</value>
</property>
<property name="connectionCacheProperties">
<props merge="default">
<prop key="MinLimit">0</prop>
<prop key="MaxLimit">100</prop>
<prop key="InitialLimit">1</prop>
<prop key="ConnectionWaitTimeout">600</prop>
<prop key="InactivityTimeout">300</prop>
<prop key="ValidateConnection">true</prop>
</props>
</property>
</bean>
答案 0 :(得分:0)
基本上你需要摆脱无效/陈旧的连接。
尝试以下一组属性:
<bean id="myDataSource" class="oracle.jdbc.pool.OracleDataSource"
destroy-method="close">
<property name="connectionCachingEnabled" value="true" />
<property name="URL" value="${jdbcUrl-myapp}" />
<property name="user" value="${jdbcUsername-myapp}" />
<property name="password" value="${jdbcPassword-myapp}" />
<property name="connectionProperties">
<value>
oracle.jdbc.timezoneAsRegion=false
</value>
</property>
<property name="connectionCacheProperties">
<props merge="default">
<prop key="MinLimit">0</prop>
<prop key="MaxLimit">100</prop>
<prop key="InitialLimit">1</prop>
<prop key="ConnectionWaitTimeout">600</prop>
<prop key="InactivityTimeout">300</prop>
<prop key="ValidateConnection">true</prop>
<prop key="testOnBorrow">true</prop>
<prop key="testOnReturn">true</prop>
<prop key="testWhileIdle">true</prop>
<prop key="validationQuery">select 1 from dual</prop>
<prop key="removeAbandoned">true</prop>
</props>
</property>
</bean>