简体   繁体   English

Spring JdbcTemplate可以等待oracle存储过程完成多长时间

[英]how long can Spring JdbcTemplate wait for an oracle stored procedure to finish

my java code is like: 我的java代码是这样的:

logger.info("start");
getJdbcTemplate().execute("call " + procedureName + "()");  

and I got the exception: 我有一个例外:

org.springframework.dao.DataAccessResourceFailureException: StatementCallback; SQL [call PRMI_UPDATE_USER_LOGIN_INFO()]; Io ERROR: Connection reset; nested exception is java.sql.SQLException: Io ERROR: Connection reset
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:257)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:428)

Maybe it's caused by the long time waiting. 可能是由于等待时间长所致。 I found that it printed " start " in log and after about 5 minutes I got the exception. 我发现它在日志中打印了“ 开始 ”,大约5分钟后,我得到了异常。

update at 2013-03-13: 在2013-03-13 更新

I got that exception not only at calling oracle stored procedure but at druid's 'JdbcUtil.close(...)': 我不仅在调用oracle存储过程时,而且在德鲁伊的'JdbcUtil.close(...)'中都获得了该异常:

com.alibaba.druid.util.JdbcUtils.close:81 - close connection error
java.sql.SQLRecoverableException: Io Error: Connection reset
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:101)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:263)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:521)
    at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:500)
    at oracle.jdbc.driver.PhysicalConnection.close(PhysicalConnection.java:3509)
    at com.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:167)
    at com.alibaba.druid.filter.stat.StatFilter.connection_close(StatFilter.java:254)
    at com.alibaba.druid.filter.FilterChainImpl.connection_close(FilterChainImpl.java:163)
    at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.close(ConnectionProxyImpl.java:115)
    at com.alibaba.druid.util.JdbcUtils.close(JdbcUtils.java:79)
    at com.alibaba.druid.pool.DruidDataSource.shrink(DruidDataSource.java:1876)
    at com.alibaba.druid.pool.DruidDataSource$DestroyConnectionThread.run(DruidDataSource.java:1694)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at oracle.net.ns.DataPacket.send(DataPacket.java:150)
    at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:180)
    at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:169)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
    at oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
    at oracle.jdbc.driver.T4C7Ocommoncall.receive(T4C7Ocommoncall.java:97)
    at oracle.jdbc.driver.T4CConnection.logoff(T4CConnection.java:487)

The druid's JdbcUtil.close method is quite simple: 德鲁伊的JdbcUtil.close方法非常简单:

 public static void close(Connection x) {
    if (x == null) {
        return;
    }
    try {
        x.close();
    } catch (Exception e) {
        LOG.debug("close connection error", e);
    }
}

the source code is : https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/util/JdbcUtils.java 源代码是: https : //github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/util/JdbcUtils.java

It should wait as long as it is needed. 只要需要它就应该等待。 Forget about various hacks which try to "detect" deadlock based on timeout delay. 忘记各种尝试根据超时延迟“检测”死锁的黑客。

  • you should find also some ORA-XXXX error. 您还应该找到一些ORA-XXXX错误。 Io ERROR: Connection reset does not look like Oracle error message, there should be some error number attached to it Io ERROR: Connection reset看起来不像Oracle错误消息,应该附加一些错误号
  • the timeout 5 minutes is very strange value. 5分钟的超时值非常奇怪。 Theoretically this can be setup also on database side. 从理论上讲,这也可以在数据库端进行设置。 As profile parameter CPU_PER_CALL but in such a case you should get an error: ORA-02393: exceeded call limit on CPU usage . 作为配置文件参数CPU_PER_CALL但是在这种情况下,您应该得到一个错误: ORA-02393: exceeded call limit on CPU usage And you connection should NOT be lost 而且您的连接不应该丢失
  • theoretically you can also have problems which dead connection detection, but 5 minutes timeout is too short for that 从理论上讲,您还会遇到死连接检测的问题,但是5分钟的超时时间太短了
  • another possible source can be ORA-600 error. 另一个可能的来源可能是ORA-600错误。 Oracle internal error, maybe your session process crashed and therefore TCP connection was lost Oracle内部错误,可能您的会话进程崩溃并因此丢失了TCP连接
  • you should contact your local DBAs and ask then for cooperation. 您应该与当地的DBA联系,然后要求合作。 They should help you better than anonymous people on the Internet forum. 他们应该比Internet论坛上的匿名人员更好地帮助您。

Maybe it's caused by the long time waiting 也许是因为长时间的等待

No it is not caused due to that 不,不是因为那引起的

As Java Doc says about DataAccessResourceFailureException 正如Java Doc所说的关于DataAccessResourceFailureException

Data access exception thrown when a resource fails completely: for example, if we can't connect to a database using JDBC. 资源完全失败时引发的数据访问异常:例如,如果我们无法使用JDBC连接到数据库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 JdbcTemplate 中创建 mySQL 存储过程 - How to create a mySQL stored procedure in a JdbcTemplate 使用 JdbcTemplate 将 Java 数组传递给 ORACLE 存储过程 - Pass an Java Array to ORACLE Stored Procedure using JdbcTemplate 如何使用JdbcTemplate在spring mvc中对存储过程或函数进行简单调用 - How to make a simple call to a stored procedure or function in spring mvc using JdbcTemplate Spring JdbcTemplate 在调用 SQLserver 存储过程时非常慢 - Spring JdbcTemplate is extremely slow when call SQLserver Stored procedure 如何使用JDBC / Spring调用Oracle存储过程,其中一些参数类型是用户定义的? - How can I call an Oracle stored procedure with JDBC/Spring where some of the parameter types are user defined? 如何使用实体管理器在 spring 中调用 oracle 存储过程? - How to call oracle stored procedure in spring using entity manager? 如何使用Spring和JDBCTemplate取消长时间运行的查询? - How can I cancel a long-running query using Spring and JDBCTemplate? 使用spring存储过程调用oracle存储过程 - Calling oracle stored procedure using spring stored procedure 如何在oracle存储过程中返回自己的类型数据? - How can I return a own type data in oracle stored procedure? 我如何在 spring jdbcTemplate 中实现分页 - how can i implement a pagination in spring jdbcTemplate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM