> Hello all,
>
> I know this has been discussed often, but I still can not find a good
> solution. I want to write an application where in one thread a database
> query is run against an oracle db. This query could run into a deadlock
> so I have to monitor this in another thread and react accordingly.
If an SQL query causes deadlock then that should send up big red flags.
Fix the problem at its source instead of looking for a workaround.
Markus Trenkle - 04 Apr 2006 00:20 GMT
> Fix the problem at its source instead of looking for a workaround.
That's alwas a good advice :-)
The problem for me is, due to a poorly designed app, I can't even see
the reason. I'm about to change that.
> Hello all,
>
> I know this has been discussed often, but I still can not find a good
> solution. I want to write an application where in one thread a database
> query is run against an oracle db. This query could run into a deadlock
> so I have to monitor this in another thread and react accordingly.
You probably don't mean deadlock, at least a simple DBMS deadlock. The
DBMS knows it before you do , and will kill one of your transactions.
If you just mean 'blocked', Java provides the Statement.cancel() call.
Joe Weinstein at BEA Systems
> I understand that the use of Thread.stop() is strongly discouraged and
> not working either. What is the best solution to this? Could I close the
[quoted text clipped - 3 lines]
> Thanks,
> Markus
Markus Trenkle - 04 Apr 2006 00:20 GMT
> You probably don't mean deadlock, at least a simple DBMS deadlock. The
> DBMS knows it before you do , and will kill one of your transactions.
Right.
> If you just mean 'blocked', Java provides the Statement.cancel() call.
> Joe Weinstein at BEA Systems
That sounds like worth trying. I could save the current executing
Statement in a public variable and call the cancel() method from the
monitor thread.
Thanks,
Markus