当我在JDBC应用程序中调用PreparedStatement.cancel()时,它实际上是否会在Oracle数据库中将其杀死? [英] When I call PreparedStatement.cancel() in a JDBC application, does it actually kill it in an Oracle database?

查看:689
本文介绍了当我在JDBC应用程序中调用PreparedStatement.cancel()时,它实际上是否会在Oracle数据库中将其杀死?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个针对Oracle 10g数据库运行的Java JDBC应用程序.我设置了PreparedStatement来执行查询,然后调用ps.executeQuery()来运行它.有时查询需要很长时间,我需要将其杀死.我还有另一个线程访问PreparedStatement对象,并在其上调用cancel().

I have Java JDBC application running against an Oracle 10g Database. I set up a PreparedStatement to execute a query, and then call ps.executeQuery() to run it. Occasionally the query takes a long time, and I need to kill it. I have another thread access that PreparedStatement object, and call cancel() on it.

我的问题是,这实际上会杀死数据库中的查询吗?还是只是从客户端上将其切断,而查询仍在Oracle的某些地方运行?

My question is, does this actually kill the query in the database? Or does it just sever it from the client, and the query is still running somewhere in the bowels of Oracle?

谢谢!

推荐答案

答案是这是实现质量问题.如果您查看 javadoc 对于Statement.cancel(),它说如果DBMS和驱动程序都支持中止SQL语句,则会发生这种情况."

The answer is that it's a quality-of-implementation issue. If you look at the javadoc for Statement.cancel(), it says it'll happen "if both the DBMS and driver support aborting an SQL statement".

根据我对各种版本的Oracle JDBC驱动程序的经验,Statement.cancel()似乎可以满足您的要求.取消查询后,查询似乎会立即停止执行.

In my experience with various versions of Oracle JDBC drivers, Statement.cancel() seems to do what you'd want. The query seems to stop executing promptly when cancelled.

这篇关于当我在JDBC应用程序中调用PreparedStatement.cancel()时,它实际上是否会在Oracle数据库中将其杀死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆