问题现象:
在java程序里访问sr,使用jdbc访问mysql的方式访问sr,
偶现: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
看了之前的论坛帖子,都说链接配置的超时时间>sr配置的时间,会有这种现象。
但是我的用法很简单:
StringBuilder urlBuilder = new StringBuilder();
urlBuilder.append(“jdbc:mysql://”)
.append(host)
.append(":")
.append(port);
Properties properties = new Properties();
properties.setProperty(“user”, user);
if (StringUtils.isNotBlank(password)) {
properties.setProperty(“password”, password);
}
return DriverManager.getConnection(urlBuilder.toString(), properties);
也没配置什么超时时间,如果要算的话,倒是用了stmt 的querytimeout:
statement = connection.createStatement();
statement.setQueryTimeout(1800);
SR超时配置: