Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / February 2007

Tip: Looking for answers? Try searching our database.

connection timeout limit?

Thread view: 
Dishan - 21 Feb 2007 05:27 GMT
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
David Harper - 21 Feb 2007 06:24 GMT
> Hi All,
> What is the best method the close the dead database connection(oracle)
[quoted text clipped - 4 lines]
> Is there anyway to set connection timeout period for the connection
> that will automatically close the connection in my souce code?

DriverManager.setLoginTimeout

From the API:

    public static void setLoginTimeout(int seconds)

    Sets the maximum time in seconds that a driver will wait while
    attempting to connect to a database.

David Harper
Cambridge, England
joeNOSPAM@BEA.com - 21 Feb 2007 15:26 GMT
> Hi All,
> What is the best method the close the dead database connection(oracle)
[quoted text clipped - 21 lines]
> 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
Dishan - 22 Feb 2007 03:35 GMT
Yes. There is a firewall between my tomcat and the database server.
Thanks for your comment!

On Feb 21, 8:26 pm, "joeNOS...@BEA.com" <joe.weinst...@gmail.com>
wrote:

> > Hi All,
> > What is the best method the close the dead database connection(oracle)
[quoted text clipped - 39 lines]
>
> - Show quoted text -


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.