java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

今天统计接口测试时发生以下异常:

java.lang.RuntimeException: org.springframework.dao.QueryTimeoutException:
### Error querying database.  Cause: java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

### The error may exist in class path resource [orm/mapper/NetTrffVehicleMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select to_char(yxqz,'YYYY') year,count(*) count         from (             select hpzl,hphm,yxqz,row_number() over(partition by hpzl,hphm order by gxsj desc) linenum             from xxx.yyyyyyyyy t2             where 1=1                 and t2.hpzl in ('02', '52')                 and t2.syxz = 'A'                 and t2.ccdjrq > sysdate - 1826                 and 7 > hdzk                 and regexp_like(t2.cllx, 'K43|K33|K26|K16|K31|K32|K34|K41|K42', 'i')                 and not regexp_like(t2.zt, 'B|C|D|E|G|I|J|L|M|O|P', 'i')         ) where linenum=1         group by to_char(yxqz,'YYYY')         order by 1
### Cause: java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

; ]; ORA-01013: 用户请求取消当前的操作
; nested exception is java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

org.springframework.dao.QueryTimeoutException:
### Error querying database.  Cause: java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

### The error may exist in class path resource [orm/mapper/NetTrffVehicleMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select to_char(yxqz,'YYYY') year,count(*) count         from (             select hpzl,hphm,yxqz,row_number() over(partition by hpzl,hphm order by gxsj desc) linenum             from xxx.yyyyyyyyy t2             where 1=1                 and t2.hpzl in ('02', '52')                 and t2.syxz = 'A'                 and t2.ccdjrq > sysdate - 1826                 and 7 > hdzk                 and regexp_like(t2.cllx, 'K43|K33|K26|K16|K31|K32|K34|K41|K42', 'i')                 and not regexp_like(t2.zt, 'B|C|D|E|G|I|J|L|M|O|P', 'i')         ) where linenum=1         group by to_char(yxqz,'YYYY')         order by 1
### Cause: java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

; ]; ORA-01013: 用户请求取消当前的操作
; nested exception is java.sql.SQLTimeoutException: ORA-01013: 用户请求取消当前的操作

        at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:76)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
        at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
        at com.sun.proxy.$Proxy83.selectList(Unknown Source)
        at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
        at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
        at com.sun.proxy.

网上查了一下,各种解决办法,但是感觉都与我的不符。
因为我的这个异常产生是在进行统计查询时产生,但是,有一个统计接口是正常的,正常的统计接口所使用的sql比较简单,而产生异常的sql则比较复杂,所以我推测是由于查询时间过长,导致程序中设置的数据库连接时间超时,从而主动断开连接,才会产生这个SQLTimeoutException: ORA-01013: 用户请求取消当前的操作的异常,但是我又不是很确定,并且我看了以下程序中的各个配置文件对数据库的连接超时时间的设置,设置的超时时间都挺长的,所以找了很长时间。
后来灵光一闪,想到会不会是mybatis中的数据库连接设置了超时(程序框架用的是公司的,尚不熟悉),于是打开mybatis的配置文件,果然,mybatis中设置了数据库连接超时时间,并且只有5秒(<setting name="defaultStatementTimeout" value="5"/>),而统计的sql查询时间在10秒以上甚至更多,于是修改配置,总算解决了,以此记录一下。

mybatis 配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
    <settings>
        <!-- Globally enables or disables any caches configured in any mapper under this configuration -->
        <setting name="cacheEnabled" value="false"/>
        <!-- Sets the number of seconds the driver will wait for a response from the database -->
        <setting name="defaultStatementTimeout" value="180"/>
        <!--打印SQL语句到控制台 -->
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
    <!-- Continue editing here -->
</configuration>
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值