wood burning stoves*
The moose likes Servlets and the fly likes Connection object in context listenter 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 » Java » Servlets
Bookmark "Connection object in context listenter" Watch "Connection object in context listenter" New topic

Connection object in context listenter

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
I have a doubt....
you write code to create connection in the context listener...for a
database that resides at a remote location..

in due course of time..if there is a problem in network where in you are not able to access the database... and sometime later..the network problem is restored...

then what happens to the connection ??

Eddy Lee Sin Ti
Ranch Hand

Joined: Oct 06, 2005
Posts: 135
The cached connection will become stale and throw exception when you try to do some database operations. You should explicitly open and close the connection whenever it is possible. By using some connection pooling data source, open connection means obtaining an opened connection from the pool and close is to return the connection back to the pool. The pool can be configured to invalidate the stale connection and recreate them.

SCJP, SCWCD, SCJWS, IBM 700,IBM 701, IBM 704, IBM 705, CA Clarity Technical<br /> <br /><a href="http://eddyleesinti.blogspot.com" target="_blank" rel="nofollow">http://eddyleesinti.blogspot.com</a>
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi Eddy,

I posted the doubt with reference to the below post...

Database Connection

Joel Hutters

Joined: Sep 07, 2006
Posts: 21
You can use autoReconnect=true on your connection url.
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Thanks Joel!!! I would check with that...
I agree. Here's the link: http://aspose.com/file-tools
subject: Connection object in context listenter
Similar Threads
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory
Connection aborted by peer: socket write error
JDBC Driver for Sql Server 2008 on Tomcat 7 get's the connection very slow.
Database connections in Servlet
Problem with ORM by Weblogic