Re: connection timeout limit?



On Feb 20, 9:27 pm, "Dishan" <dis...@xxxxxxxxx> wrote:
Hi All,
What is the best method the close the dead database connection(oracle)
while connection time is too long.?
I have a database connection pool and having some probleam (hang)
while closing expired database connection in my web site(using
tomcat5).
Is there anyway to set connection timeout period for the connection
that will automatically close the connection in my souce code?

void expire( Connection connection )
{
try
{
logger.info( "closing JDBC connection...");
connection.close(); // *** hanging here
logger.info( "JDBC connection closed successfully!");
}
catch( SQLException e )
{
e.printStackTrace();
}
}

Thanks in advance.
-Dish

Hi. No, there's no way to define ahead of time that a connection will
self-close at any particular time. Are you absolutely sure that no
other thread is using this connection?
I suspect that you have a firewall between the DBMS and driver.
If that is true, the firewall may kill sockets that haven't been
used for some time, and after that anything the driver sends on
that socket will be ignored, but from the driver's and OS's point
of view, the socket isn't dead so your close (or any other call)
may hang for a long time or indefinitely. Your best solution is
to either keep your connections busy enough that the firewall
never kills them, (even artificially with an occasional 'select 1
from dual'), or you must be sure to close your idle connections
before they are closed by the firewall.

Joe Weinstein at BEA Systems

.



Relevant Pages

  • Re: Making a database connection global
    ... connection would be opened the same amount of time (which no-one yas yet ... Anyway, if he don't want to listen, a different angle will probably not ... to reference the database connection once. ... I created a class with a static database connection and the class opens ...
    (microsoft.public.dotnet.framework.aspnet)
  • Database Connection Question
    ... we were using an asp include file with database functions ... and would open and close the database connection multiple times in 1 script. ... I don't know, the persistent connection seems much better to me, easier to ...
    (microsoft.public.inetserver.asp.db)
  • Re: garbage collection
    ... it will get a reader back.. ... you can not reuse the connection on which it opened. ... > garbage collection issue, its a logical error. ... > on database connection is, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Database Connection question
    ... the other is a standalone app and is using ... >java.sql.DriverManager for Connection. ... Every time after obtaining a ... >My task is to write generic code for database connection to be used in both ...
    (comp.lang.java.programmer)
  • RE: Activated Event Vs. other Events
    ... your function to check the database connection ... > The form has to render itself completely first, then attempt a connection, ... > I placed all related code in the Load event, just to realize this code gets ...
    (microsoft.public.dotnet.framework.windowsforms)