[英]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. 忘记各种尝试根据超时延迟“检测”死锁的黑客。
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错误消息,应该附加一些错误号 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 而且您的连接不应该丢失 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.