File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Cancel database query.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Cancel database query...." Watch "Cancel database query...." New topic
Author

Cancel database query....

Anu pama Dande
Greenhorn

Joined: Mar 06, 2006
Posts: 12
i have a search screen developed in struts which results in different number of output records.

i want to make it user-friendly.

once user starts searching i want to show a cancel button on the page... n if query is taking more than a minute... then user should be able to cancel the query and start a new query.

my question is ... if user clicks on cancel button ... we can take him back to search screen and .. he can re-search but... the previous query will still be running on database side. How do I cancel that in action class?? n keep the database resources free from the previous query.

--Anupama
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Telling a query to stop running is no simple matter. The main problem is that when a query takes a long time to run, the overwhelming majority of that processing time is occuring on the database server, not in the application server. So, if you were to run a large JDBC query, the code would run very quickly until you got to:

ResultSet rs = statement.executeQuery();

at which time the JDBC code is waiting on the database server to execute the query and return a result.

You can use threading to run the query in the background. If you do this, you can certainly allow the user to cancel out of waiting to retrieve a result, but in my opinion, once a query is running, there isn't much point in trying to stop it.


Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cancel database query....
 
Similar Threads
Yes or No Confirmation alert Msg Box??
My first mobile application
Cancel button on multiactioncontroller
Terminate long query in Hibernate?
Catching windows Print Dialog through javascript