Interrupting a JDBC query
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Lasse_Koskela
Posted On:   Wednesday, April 9, 2003 11:41 AM

Hi all, I'm wondering whether it is possible to interrupt a thread that is in the middle of executing a database query using java.sql.Connection#executeQuery() ...? What I'm trying to do is to have a timeout for the query - if the specified time limit is reached, the query processing is interrupted and some kind of "you interrupted" page is shown to the browser. I was thinking about launching one thread for performing the executeQuery() and another for the timer. The timer thread would then call sqlThread.interrupt() . Is this ok? Is there a better way?    More>>

Hi all,


I'm wondering whether it is possible to interrupt a thread that is in the middle of executing a database query using java.sql.Connection#executeQuery() ...?


What I'm trying to do is to have a timeout for the query - if the specified time limit is reached, the query processing is interrupted and some kind of "you interrupted" page is shown to the browser.


I was thinking about launching one thread for performing the executeQuery() and another for the timer. The timer thread would then call sqlThread.interrupt() .


Is this ok? Is there a better way?

   <<Less

Re: Interrupting a JDBC query

Posted By:   Edward_Harned  
Posted On:   Wednesday, April 9, 2003 06:37 PM

You have the right idea.


You don't need a timer thread. Just time the SQL thread. A simple wait() / notify() between both threads works fine.

About | Sitemap | Contact