Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / April 2006

Tip: Looking for answers? Try searching our database.

Interrupt blocked database query

Thread view: 
Markus Trenkle - 03 Apr 2006 06:45 GMT
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 - 03 Apr 2006 08:40 GMT
> 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.
Joe Weinstein - 03 Apr 2006 16:45 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.