Recover from JDBC failed connection [message #341083] |
Sat, 16 August 2008 02:07 |
bztom33
Messages: 95 Registered: June 2005
|
Member |
|
|
I made sure that executeQuery() does not properly time out after
calling setQueryTimeout() by running this loop:
System.err.printf("[%s] establishing connection\n", System.currentTimeMillis());
c = oracleDataSource.getConnection();
System.err.printf("[%s] connection established\n", System.currentTimeMillis());
s = c.createStatement();
s.setQueryTimeout(1);
for (;;) {
System.err.printf("[%s] executing query \n", System.currentTimeMillis());
r = s.executeQuery("select 1 from dual");
System.err.printf("[%s] query returned\n", System.currentTimeMillis());
r.close();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
}
You can see from the output that it never times out:
[1137290872367] establishing connection
[1137290873514] connection established
[1137290873514] executing query
[1137290873544] query returned
[1137290874550] executing query
[1137290874552] query returned
[1137290875558] executing query
[1137290875560] query returned
[1137290876566] executing query
[1137290876568] query returned
(ethernet cable unplugged...)
[1137290877574] executing query
(i waited a very long time, and nothing happened...)
|
|
|
|