• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to extraxt StaleConnectionException from DataAceessException

 
swapnil dangore
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Secrist
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic