Interrupt blocked database query  
Author Message
markus.trenkle





PostPosted: 2006-4-3 13:45:00 Top

java-programmer, Interrupt blocked database query 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.

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
socket and see what is left from the database connection? Where do I get
the socket then? Any other ideas?

Thanks,
Markus
 
noone





PostPosted: 2006-4-3 15:40:00 Top

java-programmer >> Interrupt blocked database query On Mon, 03 Apr 2006 07:45:12 +0200, Markus Trenkle wrote:

> 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.




 
Joe Weinstein





PostPosted: 2006-4-3 23:45:00 Top

java-programmer >> Interrupt blocked database query

Markus Trenkle wrote:

> 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
> socket and see what is left from the database connection? Where do I get
> the socket then? Any other ideas?
>
> Thanks,
> Markus

 
 
markus.trenkle





PostPosted: 2006-4-4 7:20:00 Top

java-programmer >> Interrupt blocked database query Joe Weinstein <email***@***.com> wrote:

> 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
 
 
markus.trenkle





PostPosted: 2006-4-4 7:20:00 Top

java-programmer >> Interrupt blocked database query noone <email***@***.com> wrote:

> 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.