"I'm not back." - Bill Harding, Twister
Jim,
I did try them all, but they did not work. The method cancel() did nothing because informix jdbc does not support it. The method close() could not execute. It appeared that the query thread locked the prepapredStatement object and prevented the monitor thread from close() the prepraredStatement. Stopping the query thread was interesting. After stopping the query thread, I checked whether the thread was alive. The thread was indeed died, but the query kept running.
"I'm not back." - Bill Harding, Twister
If you choose to use a boolean flag to indicate when it's time to stop, be sure to declare the flag volatile in case you should find your code running in a VM that keeps thread local copies of fields.
David,
while(flag){
...
prepraredStatement.executeQuery("Sql");
...
...
}
volatile flag will not work because the operation preparedStatement.executeQuery() consumes much time (sometimes it takes up to 5 min).
"I'm not back." - Bill Harding, Twister
"I'm not back." - Bill Harding, Twister
You might see if it's possible to find a different driver for your Informix DB, one that does support cancel(). Especially if you're currently using a JDBC-ODBC bridge or something like that. Buf if you've tried the most full-featured Informix driver(s) you can find and cancel() still doesn't work, you may be stuck with either (a) switching to another DB, or (b) living with the inability to cancel operations.