Interrupt blocked database query

M

Markus Trenkle

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
 
N

noone

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

Joe Weinstein

Markus said:
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
 
M

Markus Trenkle

Joe Weinstein said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top