Oracle连接/查询超时 [英] Oracle connection/query timeout
问题描述
是否可以为Oracle数据库查询指定连接/查询超时?在Oracle方面还是在Oracle的JDBC驱动程序(10.2.0.4)中?那么,那个Java客户端只是在2分钟之后又返回了一个错误,而不是等到Oracle完成执行查询之后?
Is it possible to specify connection/query timeout for the Oracle database queries? Either on Oracle side or in Oracle's JDBC driver (10.2.0.4)? So, that Java client just got an error back after, let's say, 2 minutes instead of waiting until Oracle finishes executing the query?
推荐答案
如果在事务上下文中执行查询,则JTA事务监视器的事务超时值将决定查询超时.此配置从一台应用程序服务器到另一台应用程序服务器.
If you are executing the query in the context of a transaction, the transaction timeout value of the JTA transaction monitor will be the determinant to query timeout. The configuration for this depends from one application server to another.
At an individual query level (in the absence of a JTA transaction monitor), the setQueryTimeout method can be used to set the timeout on the execution of a Statement/PreparedStatement/CallableStatement object.
更新
setQueryTimeout(尽管它是有效的)(至少是J2SE客户端).它通过JDBC驱动程序工作,执行到Oracle数据库服务器的完整往返.然后,由数据库决定是否停止执行查询.对于时间紧迫的应用程序,请不要依赖它.
setQueryTimeout is not to be relied on, although it works (atleast from a J2SE client). It works via the JDBC driver performing a full round-trip to the Oracle database server. Then, it is upto the database to halt execution of the query. Don't rely on it for time critical applications.
这篇关于Oracle连接/查询超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!