Oracle的JDBC查询超时是如何实现的?

发布于 2024-08-23 16:48:49 字数 279 浏览 3 评论 0原文

我很好奇 Oralce JDBC 瘦客户端是如何实现查询超时的。 这可以通过调用 java.sql.Statement 的 setQueryTimeout(int secondary) 来设置 方法。

这是在客户端的驱动程序本身中实现的吗?是一个 新线程产生并加入?或者 JDBC 驱动程序只是简单地 向Oracle发送一个参数,然后强制超时?

超时后,客户端上有哪些资源 数据库都发布了,还有哪些闲逛? Oracle 是否继续 即使客户端放弃了它还是运行查询 终止?客户端还有游标对象吗?

谢谢

I was curious as to how the Oralce JDBC thin client implement query timeout.
This can be set by calling java.sql.Statement's setQueryTimeout(int seconds)
method.

Is this implemented in the driver itself on the client side? Is a
new thread spawned and joined? Or does the JDBC driver simply
send a parameter to Oracle, and then it enforces the timeout?

After the timeout is reached, which resources on the client and
database are released, and which hang around? Does Oracle continue
to run the query even though the client abandoned it or is it
terminated? Is there still a cursor object on the client side?

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

最笨的告白 2024-08-30 16:48:49

根据 Oracle JDBC 常见问题解答

语句超时线程。如果您执行任何超时的语句,则会创建此线程。 无论有多少语句或连接,都只会创建一个线程。该线程将持续虚拟机的生命周期。

According to Oracle JDBC FAQ

Statement timeout thread. This thread is created if you execute any statement with a timeout. Only one thread is created no matter how many statements or connections. This thread lasts the lifetime of the VM.

指尖凝香 2024-08-30 16:48:49

Tanel Poder 写了一篇 关于取消如何通过 OCI(Oracle 调用接口)工作的文章
我想 JDBC 也做了类似的事情。如果您使用厚驱动程序,通过 OCI,您可以尝试跟踪会话(通过设置 sqlnet.ora)并查看记录的内容。

Tanel Poder wrote an article on how a Cancel works through the OCI (Oracle Call Interface).
I guess something similar is done for JDBC. If you are using the thick driver, through OCI, you could try tracing the session (through settings sqlnet.ora) and see what gets recorded.

后eg是否自 2024-08-30 16:48:49

当使用 setTimeOut 方法查询实际超时时,Oracle 服务器会抛出一个带有 Oracle 错误代码 ORA-01013 - 用户请求取消当前操作 的 SQL 异常。

这意味着该操作已被优雅地取消(就 Oracle 而言/尽可能多的 Oracle 可以) - 因为是 Oracle 发送此消息。

When a query actually timesout when using the setTimeOut method, a SQL exception with the Oracle error code ORA-01013 - user requested cancel of current operation is thrown from the oracle server.

This would mean that the operation has been cancelled gracefully (as far as oracle is concerned/as much oracle can) - because it is oracle sending this message.

眸中客 2024-08-30 16:48:49

我确实知道,当达到超时时,查询不会在服务器端继续。在超时之前或之后,有一些意图/信号选项发送到服务器,以指示服务器应该停止。我通过在服务器上的各个 V$ 表中查看查询是否正在运行来验证这一点。 (V$SESSION、V$SQL 等)

I do know that the query does not continue on the server side when the timeout is reached. There is some intention/signal option sent to the server either before or after the timeout is reached to indicate it the server should stop. I have verified this by looking on the server in various V$ tables to see if the query is running. (V$SESSION, V$SQL, etc)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文