• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connection.close hangs

 
Mahesh Sivaraman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a connection which executes an Oracle Procedure through CallableStatement. The procedure takes about 5 minutes to complete. When i call the close method of that connection from another thread, the connection hangs. It will remain in that state until the statement execution is over. I am having problems because of this since i call the connection close method from a static synchronized method. No other threads can call any of the other methods of my class until the connection.close method returns. Is thr any way by which i can immediatly terminate the connection ? I don't want to remove the synchronized property of the method. I am using Oracle thin driver.
Can anyone shed some light on it.
Thanx in Advance
Regards
Mahesh
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mahesh,
I may be misinterpreting your question, but I think you are looking for a way to cancel the execution of your stored procedure when it takes too long to complete.
Have you tried the "cancel()" and/or "setQueryTimeout()" methods in java.sql.Statement?
I suggest you verify whether they are supported by Oracle's JDBC driver. Perhaps check the Oracle documentation.
Hope this helps.
Good Luck,
Avi.
 
Mahesh Sivaraman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avi,
Thanx for replying. I cannot use setQueryTimeOut method because, the time taking for completing the procedure is perfectly legal. The procedure does a lot of things before it completes. And for calling the cancel method i don't have the reference of the Statement object. One thread starts the execution. Its a servlet environment. Another http request(another thread) will try to close the connection which started the procedure execution. Anyway i'll try to cancel the execution using cancel() method.
Meanwhile if u have any other ideas for immediatly terminating the connection please tell me.
Thanx for ur Co-operation
Regards
Mahesh
 
Mahesh Sivaraman
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Avi,
I tried cancelling the statement execution through a sample program. It worked. Thanx. But as i said earlier, i don't have the reference of the Statement object. Is thr any way through which i can get the references (as a collection or something) of the currently active statements in a connection. I searched in the JDBC API but cudn't find one. Any idea ?
Thanx and Regards
Mahesh
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic