interrupt a jdbc connection thread
I have a program which spawn a thread connecting to DB.
When the DB or network is down and cannot open the connection, it hangs there.
// load jdbc driver
// declare varialbles
Connection con = DriverManager.getConnection(url);
I tried to call Thread.interrupt() from parent but it seems like it's waiting for the connection to finish.
Is there a way to interrupt the JDBC connection in a thread?
not working for jdbc2.1 and db2 v8
thanks. i've tried it. i forgot to mention that the environment i'm working on is DB2 v8 and JDBC 2.1.
DB2 v8 doesn't support DriverManager.setLoginTimeout() from JDBC 2.1 Core API. it has no effect.
Methods, Data Types, and Features That Are Not Supported by DB2 JDBC Drivers
that's why i need to find a way to interrupt the connection explicitly, and i'm also curious how to interrupt a thread if similar cases happen.
the method you mentioned works for DB2 v9 with JDBC 3.0.