----- Original Message ----- From: "Nathan Smith" <[EMAIL PROTECTED]> To: "Tomcat Users List" <[EMAIL PROTECTED]> Sent: Sunday, July 28, 2002 7:28 PM Subject: runaway queries with tomcat and Progress database using JDBC driver.
> Does anybody have any ideas on how I might implement the best practical way >to shutdown or stop a query once it has been executed in a servlet and has >taken too long to return back any data. Why is it "taking too long?" In general, once you call statement.executeXXX(), the call is translated and passed on to your database. You can't stop that unless your database has some control software to examine and stop running queries. Make sure your SQL is doing what you want it to and not trying to return the cross-product of two or more tables or something else that would take a long time. But of course, you could want it to take a long time... For example, I've got a Servlet that uploads quite a bit of data into my database, and it takes about 10 to 15 minutes, but I expect that, so it's cool. Since I *don't* fork this job off, the servlet does not immediately return, and I get no webpage back for that time, and the request winds up timing out. But the servlet (and the database) is still chugging merrily away... >One solution is to execute the query within a new thread and then try and make >the thread exit after a certain amount of time has elapsed. The difficult part >of this will stopping the thread also stop the process running on the server, >as once the query is executed it gets communicated through the driver to the >SQL engine and then to the database. The database is probably doing something; and unless your database software is shoddy, that something is probably exactly what you told it to do, and it's not merely timing out or hanging.. If you want the Servlet to return immediately, then the solution is to pass that task off to another thread, which I'll call SQLWorker. Depending on the nature of the task and the way you write the SQLWorker, you may or may not be able to stop the query in the database server. If you are only executing 1 SQL statement, then stopping the SQLWorker won't do much good because the database already is processing the query. On the other hand, if you've got a whole bunch, stopping the SQLWorker will stop it from sending further queries. Hope this helps.. Regards, Michael -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
