title: How to force timeout for DriverManager.getConnection() method call?
body: <p>I have an application which will establish DB connection with MySQL and execute queries. Sometimes the <code>DriverManager.getConnection()</code> method call takes 2 seconds and sometimes it takes 30 seconds. Is there any way to control this method to timeout after 2 seconds?</p>
  
  <p><code>DriverManager.setLoginTimeout()</code> doesn't seem to work.</p>
  
  <p>Actually, am able to set timeout for <code>statement.executeQuery()</code> by sleeping the thread for my timeout value and closing the connection after wakeup. But its the connection establishment part where I couldn't really set the timeout.</p>
  
  <p>Would appreciate any help.</p>