File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Abort executing query without setting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Abort executing query without setting "timeout" attribute in IBatis?" Watch "Abort executing query without setting "timeout" attribute in IBatis?" New topic

Abort executing query without setting "timeout" attribute in IBatis?

Vijay Kandaswamy

Joined: Sep 18, 2012
Posts: 6

A query is taking more than a minute to retrieve the data (Due to larger volume of data) from the database.
I need to stop its execution.
I know that, we can set "timeout" attribute in the select tag (For a single query alone) or "defaultStatementTimeout" attribute in settings tag (SqlMapConfig.xml - For all the query) to forcibly terminate the query in execution.


By doing the above configuration, IBatis will throw "User cancelled request" error and terminates the execution.
Do we have any other way to terminate the execution?

My Scenario:

When user requests for 3 years data, it takes more than a minute to fetch data from the database.
In the meantime, when the user requests for 1 day's data or sends a "cancel" request, I have to forcibly terminate the previous execution (3 years data retrieval) because it is affecting performance even with limited number of users.

I didn't used any of the setting above.

Please provide me solution for this.
Thanks in advance .

Thanks & Regards
Vijayabalakrishnan K
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Welcome to the Ranch!

You should probably limit the number of concurrent requests for large amounts of data somehow (maybe down to one at a time?). Cancelling a request that has already processed substantial amount of data just because another request has arrived is a big waste of resources. The "small" requests should then be allowed alongside the "big" one(s), it will perhaps take longer, but so what - if someone needs to process such requests, the system must be sized up properly.

If you have a single application server, you could probably implement it easily there. If you have a more distributed application, you might use some database concurrency/locking mechanism for that.
I agree. Here's the link:
subject: Abort executing query without setting "timeout" attribute in IBatis?
It's not a secret anymore!