Subject | DriverManager.setLoginTimeout() |
---|---|
Author | nagypapi |
Post date | 2005-08-25T00:12:19Z |
Symptom:
Whatever I set the DriverManager's timeout to (ex 10 or 40), Jaybird
will only timeout after 25 secs
System:
Firebird 1.5.2
JayBird 1.5.5
Java 1.5_04
SuperComputer with lots of foodpieces in it
destination computer was one I just shut down beforehand
Class to test stuff (alter code as needed):
import java.sql.*;
class JDBCTimeout {
public static void main(String args[]) {
int timeoutInSecs=10;
Connection conn=null;
if(args!=null&&args.length>0)
try{timeoutInSecs=Integer.parseInt(args[0]);} catch(Exception e)
{e.printStackTrace(System.out);}
DriverManager.setLoginTimeout(timeoutInSecs);
System.out.println("Set DriverManager's timeout to:
"+DriverManager.getLoginTimeout());
try{ Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
} catch(Exception e) {e.printStackTrace(System.out);}
long start=System.currentTimeMillis();
try {
conn = DriverManager.getConnection(
"jdbc:firebirdsql://<some unreachable computer's
IP>:3050/pizzadb?lc_ctype=UNICODE_FSS&sql_role_name=<role>","<user>","<pass>");
System.out.println("Connected to DB in
"+(System.currentTimeMillis()-start)+" milliseconds");
} catch(Exception e) {
System.out.println("UNABLE to connect to DB in
"+(System.currentTimeMillis()-start)+" milliseconds");
e.printStackTrace(System.out);
}
try{conn.close();}catch(Exception e) {e.printStackTrace(System.out);}
System.exit(0);
}
}
Whatever I set the DriverManager's timeout to (ex 10 or 40), Jaybird
will only timeout after 25 secs
System:
Firebird 1.5.2
JayBird 1.5.5
Java 1.5_04
SuperComputer with lots of foodpieces in it
destination computer was one I just shut down beforehand
Class to test stuff (alter code as needed):
import java.sql.*;
class JDBCTimeout {
public static void main(String args[]) {
int timeoutInSecs=10;
Connection conn=null;
if(args!=null&&args.length>0)
try{timeoutInSecs=Integer.parseInt(args[0]);} catch(Exception e)
{e.printStackTrace(System.out);}
DriverManager.setLoginTimeout(timeoutInSecs);
System.out.println("Set DriverManager's timeout to:
"+DriverManager.getLoginTimeout());
try{ Class.forName("org.firebirdsql.jdbc.FBDriver").newInstance();
} catch(Exception e) {e.printStackTrace(System.out);}
long start=System.currentTimeMillis();
try {
conn = DriverManager.getConnection(
"jdbc:firebirdsql://<some unreachable computer's
IP>:3050/pizzadb?lc_ctype=UNICODE_FSS&sql_role_name=<role>","<user>","<pass>");
System.out.println("Connected to DB in
"+(System.currentTimeMillis()-start)+" milliseconds");
} catch(Exception e) {
System.out.println("UNABLE to connect to DB in
"+(System.currentTimeMillis()-start)+" milliseconds");
e.printStackTrace(System.out);
}
try{conn.close();}catch(Exception e) {e.printStackTrace(System.out);}
System.exit(0);
}
}