aspose file tools*
The moose likes Spring and the fly likes Unable to extraxt StaleConnectionException from DataAceessException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Unable to extraxt StaleConnectionException from DataAceessException" Watch "Unable to extraxt StaleConnectionException from DataAceessException" New topic
Author

Unable to extraxt StaleConnectionException from DataAceessException

swapnil dangore
Ranch Hand

Joined: Jun 05, 2006
Posts: 46
Hi All,
We are using Spring JDBC in our application.. We have DB2 as backend. We are using DB2 Type 4 Driver for DB communication.
Our requirement is Whenever we get Stale Connection, we should retry 3 times.. See below code that I have written.



But,to my surprise, if(dae.getCause() instanceof StaleConnectionException) always returns me false, even though the cause is com.ibm.websphere.ce.cm.StaleConnectionException.

I also tried using if(dae.getRootCause() instanceof StaleConnectionException){ .

Could anybody tell me how to deal with StaleConnectionException in Spring.

Cheers<br />-------------<br />Swapnil<br /> <br />SCJP5-81%<br /> <br />"Dictionary is the only place where Success come before Work"
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
have you tried using 'contains'? As in:


This should tell you if the StaleConnectionException is found in the nested exception list.
swapnil dangore
Ranch Hand

Joined: Jun 05, 2006
Posts: 46
Thanks Mark for the reply.

I tried your solution. but, even that also didn't worked for me.

IS this proble related to Websphere 6.1.

I also, have some plain JDBC code like below.



If StaleConnection occures, StaleConnection catch block does not execute on WAS6.1. Same code works on WAS5.

Could anybody tell me what I am missing. Has it to do anything with any missing JARS.
Mark Secrist
Ranch Hand

Joined: Jul 01, 2003
Posts: 89
I'm not too familiar with WAS 6.1. However, it seems that if you have the StaleConnectionException in the exception list, I'd have expected this to work. You may want to talk to some WAS experts. I'm guessing something must have changed but I'm not sure what.

Can you possibly post the exception stack from the two cases where you can and can't catch the exception? Maybe we can figure something out from that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to extraxt StaleConnectionException from DataAceessException