Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

How to force timeout for DriverManager.getConnection() method call ? (no replies)

$
0
0
How to force timeout for DriverManager.getConnection() method call ?



I have an application which will establish DB connection with MySQL and execute queries. Sometimes the DriverManager.getConnection() method call takes 2 seconds and sometimes it takes 30 seconds. Is there any way to control this method to timeout after 2 seconds?

DriverManager.setLoginTimeout() doesn't seem to work.

Actually, am able to set timeout for statement.executeQuery() 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.

Would appreciate any help.

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>