In SQL Developer, clicking on the Cancel Task button stops the execution of a query immidiately. I have to implement the same functionality in our project.

I am using BC4J as an ORM tool to execute the queries. I have to cancel a search query execution called thorugh view objects that calls several database functions/procedures to get the result.
I have tried using viewObject.cancelQuery(); but it doesn't have any effect; the query keeps executing to the end.
I am connected through JDBC connection pooling, handled by BC4J.
My suggestion is
Runnable implementation which
cancel() method which
cancelQuery resp. cancel of your query<query thread>.interrupt(); for this purpose you need to store a reference to your query thread in <query thread>. Active IO operations are sometimes interrupted by this signal!InterruptedException and SQLException in run(): if these exceptions are catched rollback transaction (if one is started at all for a read only query)Thread.currentThread().isInterrupted() after each statement, cancel() if result is truecancel() of your query runnableThere are helper classes in Swing as well as in Eclipse RCP which support this design.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With