Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

stale connection exception

 
kuldeep oli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

we were using stale connection exception in our application and our server was websphere.

now we have to migrate 2 tomcat..and stale connection exception is not supported here..pls suggest me in replacement of this an equivalent exception.in tomcat 5X server..

thanks,
kuldeep
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain what exactly that stale connection exception of Websphere is, and how and for what purposes you use it in your application? For which kind of connections do you use it?
 
kuldeep oli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
Can you explain what exactly that stale connection exception of Websphere is, and how and for what purposes you use it in your application? For which kind of connections do you use it?
 
kuldeep oli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jesper Young:
Can you explain what exactly that stale connection exception of Websphere is, and how and for what purposes you use it in your application? For which kind of connections do you use it?



staleconnection exception is subclass of sqlexception used to print proper messages,reasons... when connection goes down
we are using it to catch sqlexceptions.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which kind of connections? I guess database connections, if it's a subclass of SQLException? Are you using this to see if your application lost the connection to the database?

Are you using a connection pool? Web applications should always let the application server manage database connections in a connection pool. Your app should not be holding on to a database longer than necessary. If you let the application server manage database connections, then you don't need to add this kind of logic in your application.
 
kuldeep oli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catch(com.ibm.websphere.ce.cm.StaleConnectionException sce)
{
//logger.debug("***** Stale Connection failure :"+sce.getMessage () );
if (numOfRetries < 5)
{
retry = true;///it tries to re_establish connection whenever down,stale,�.
numOfRetries++;
//logger.debug("***** Retry # "+numOfRetries );
}
else
{
retry = false;
//logger.debug("***** Failed after "+numOfRetries+" retries, throwing exception");
throw sce;// throws exception with proper reason ,sql state ,vendor code.[extendds sql exception]
}
/////////////************/////////

the code looks like above.. and we cant remove this code and create any new custom class as we are not allowed .

we are using connection pooling...
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kuldeep oli:
the code looks like above.. and we cant remove this code and create any new custom class as we are not allowed .

we are using connection pooling...

Well, if you're not allowed to change any of this code, then you're not going to get it working on Tomcat, because the code is using an IBM Websphere-specific class that doesn't exist in Tomcat...
 
kuldeep oli
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But can we implement the same as websphere people have done..?

Will you be able to help me regarding this..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic