wood burning stoves 2.0*
The moose likes Tomcat and the fly likes stale connection exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "stale connection exception" Watch "stale connection exception" New topic
Author

stale connection exception

kuldeep oli
Greenhorn

Joined: Dec 30, 2007
Posts: 5
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
kuldeep oli
Greenhorn

Joined: Dec 30, 2007
Posts: 5
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

Joined: Dec 30, 2007
Posts: 5
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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

Joined: Dec 30, 2007
Posts: 5
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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

Joined: Dec 30, 2007
Posts: 5
But can we implement the same as websphere people have done..?

Will you be able to help me regarding this..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stale connection exception
 
Similar Threads
Tomcat deployment problem in netbeans.
java.sql.SQLException: [SQL0901]
Tomcat stops on web service exception
stale jdbc Connection
Tomcat hangs up