how to control DriverManager.getConnection timeout period
Posted by: Tan Hobby
Date: February 02, 2015 07:34AM

Hi,
I use mysql ndb7.x, I try to write one simple java programe to detect when ndb can't be connected, but I found DriverManager.getConnection will not return but it will timeout after 20 minutes, so my programe can't tell me if connection can be setup or not until 20 minutes later. so I want to know how to control the DriverManager.getConnection timeout period, e.g. like 20 seconds. Or if there is a better way to detect Mysql ndb(cluster) can't be access through sqlnode. Thanks

my simple code is as below, your comments are highly appreciated,
Properties prop = new Properties();
prop.setProperty("connectTimeout", "5000");
prop.setProperty("socketTimeout", "5000");

return DriverManager.getConnection(
"jdbc:mysql:loadbalance://sc-1:3307,sc-2:3307/table?"
+ "localSocketAddress=xxxx", prop);

Options: ReplyQuote


Subject
Written By
Posted
how to control DriverManager.getConnection timeout period
February 02, 2015 07:34AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.