List:MySQL and Java« Previous MessageNext Message »
From:Brandon Bell Date:April 1 1999 6:47pm
Subject:MM-MySQL Connection Timeout
View as plain text  
I'm using mm.mysql.jdbc-1.1f on Solaris 2.6 with Java 1.2_01 and I'm
having a problem timing out if the MySQL database isn't available to
connect to.

I've tried this without setting the login timeout, and with setting
the login timeout to 10 seconds as a test (the default seems to be 0,
but I'm unclear if this means wait forever or don't wait at all),
using:
  DriverManager.setLoginTimeout(10);
According to the DriverManager API docs, setLoginTimeout "Sets the
maximum time in seconds that a driver will wait while attempting to
connect to a database." which sounds exactly like what I need to do.

However, when my code gets down to where I try and establish the
database connection:
  Connection con = DriverManager.getConnection(dbURL, dbAcct, dbPwd);
the program hangs on this line with the CPU redlining at 100%
utilization.

If the MySQL database is up and running okay, then everything works as
expected.  I'm in the testing phase of our project now and came across
this problem while trying to gracefully handle what happens if the
database isn't available...

Any help and/or suggestions would be appreciated!

--
Brandon Bell
Sr. Systems Analyst, BCIT Technology Centre
Group for Advanced Information Technology
Tel: 604.432.8533, Fax: 604.436.1297
http://www.gait.bcit.bc.ca/


Thread
MM-MySQL Connection TimeoutBrandon Bell1 Apr