File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Detecting inifite looping of Stored proc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Detecting inifite looping of Stored proc" Watch "Detecting inifite looping of Stored proc" New topic
Author

Detecting inifite looping of Stored proc

Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Hello there,
I use a callable statement that executes a Stored Procedure (Oracle), due to some logical bug, this stored proc is not returning (but just looping infinitely).
How do I control this time-out?
I am not using a fixed connection created from DriverManager (instead of obtaining one from conn pool, due to architectual issues).
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42267
    
  64
Um, wouldn't it be easier to just fix the bug? Why do you want to work around it?


Ping & DNS - my free Android networking tools app
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Well, I do want the pl/sql developer to fix the bug.
But lets say its not an infinite loop, but it takes an hour. Should my JDBC call just hang on to it helpless.
In such case, wouldn't some JVM Thread monitor thinks its a hung thread and kill it?
So I am wondering if I can handle this at Java layer.
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
The interface java.sql.Statement defines the method

public void setQueryTimeout(int seconds) throws SQLException

Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds. If the limit is exceeded, an SQLException is thrown.

JavaDoc
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
That worked perfectly for me. Thanks much!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Detecting inifite looping of Stored proc