我遇到了与数据库连接的问题,在应用程序暂停一段时间后,我返回并输入以下错误
01-08-2014 04:45:33 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() para servlet springapp lanzó excepción
org.springframework.dao.DataAccessResourceFailureException:
### Error querying database. Cause: java.sql.SQLRecoverableException: Error de E/S: Software caused connection abort: recv failed
这是我的oracle数据源
<!-- Load properties with PlaceHolder -->
<context:property-placeholder location="WEB-INF/properties/*.properties" />
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<aop:config>
<!-- aop:advisor pointcut="execution(* *..Service.*(..))" advice-ref="txAdvice"/ -->
<aop:pointcut id="fooServiceOperation" expression="execution(* cl.bbr.proceso.maestro.proceso.ProcesoMaestro.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation"/>
</aop:config>
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<!-- all methods starting with 'get','is','select' are read-only -->
<tx:method name="get*" read-only="true"/>
<tx:method name="is*" read-only="true"/>
<tx:method name="select*" read-only="true"/>
<!-- other methods use the default transaction settings (see below) -->
<tx:method name="*" rollback-for="Exception" />
</tx:attributes>
</tx:advice>
<tx:advice id="noTxAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" propagation="REQUIRES_NEW" />
</tx:attributes>
</tx:advice>
编辑05/08/2014 数据库:ORACLE 11G 春季版:3.0 TOMCAT 6.0
希望你能帮助我。答案 0 :(得分:1)
将这些行添加到dataSource bean解决了这个问题:
<property name="validationQuery" value="SELECT 1 from dual" />
<property name="testOnBorrow" value="true" />
关于验证查询,您可以在此问题的答案中阅读:What is a validationQuery with respect to databases and JNDI?
&#34; testOnBorrow&#34;意味着在每个查询执行之前都会执行validationQuery。