JDBC DriverManager.getConnection Timout
843854Jan 14 2002 — edited May 31 2002When trying to getConnection to an invalid host, the system will hang. So I am trying to find a way to set the Timout parameter for DriverManager.getConnection(...). I used DriverManager.setLoginTimeout(10);, but it doesn't work. The system still hangs. Here's part of my code: Any comment is appreciated. Thanks.
try {
DriverManager.setLoginTimeout(10);
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
String connStmt = "jdbc:oracle:thin:@" + oesHost+ ":" + oesPort + ":" + oesSID;
conn = DriverManager.getConnection(connStmt, oesUser, oesPassword);
.......
} catch (SQLException e) {
throw e;
}
finally {
conn.close();
}