This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Servlets and the fly likes Connection object in context listenter Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Connection object in context listenter" Watch "Connection object in context listenter" New topic
Author

Connection object in context listenter

A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 973
Hi,
I have a doubt....
Suppose,
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 ??

Regards
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: 973
Hi Eddy,

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

Database Connection

Regards
Joel Hutters
Greenhorn

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

Joined: Jul 04, 2004
Posts: 973
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
Database connections in Servlet
JDBC Driver for Sql Server 2008 on Tomcat 7 get's the connection very slow.
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory
Problem with ORM by Weblogic
Connection aborted by peer: socket write error