admin管理员组文章数量:1289362
When configuring a DB2 LUW connection in Spring Boot using Tomcat, I am seeing issues upon HADR failover where the alternate server is not properly failed over to. Post failover I receive SQLCODE=-1776 indicating the connection is attempting to be made to a standby database. A manual application restart resolves the issue as it will then connect to the alternate failover hostname, so I know the property configurations are working.
Below is the sample java code tested with:
Connection conn = null;
try {
System.out.println("Connecting to the primary DB2 server...");
Properties info = new Properties();
info.put("user", DB_USER);
info.put("password", password);
info.put("clientRerouteAlternateServerName", CLIENT_REROUTE_ALTERNATE_SERVER_NAME);
info.put("clientRerouteAlternatePortNumber", CLIENT_REROUTE_ALTERNATE_PORT_NUMBER);
info.put("maxRetriesForClientReroute", MAX_RETRIES_FOR_CLIENT_REROUTE);
info.put("retryIntervalForClientReroute", RETRY_INTERVAL_FOR_CLIENTREROUTE);
info.put("enableSeamlessFailover", ENABLE_SEAMLESS_FAILOVER);
conn = DriverManager.getConnection(JDBCURL, info);
String hostName = getHostName(conn);
return "Connected to "
+ conn.getMetaData().getDatabaseProductName()
+ " "
+ conn.getMetaData().getDatabaseProductVersion()
+ " "
+ HOST_NAME_LABEL
+ hostName;
} catch (SQLException ex) {
System.err.println("An error occurred during connection or query execution:");
ex.printStackTrace();
return "Failed to make connection!";
} finally {
if (conn != null) {
try {
conn.close();
System.out.println("Connection closed.");
} catch (SQLException e) {
// Ignore closing errors
}
}
}
I believe this issue may lie within Spring/Tomcat as replicating this code in plain Java + JDBC results in this issue going away with the alternate server properly failed over to. For more context, we had similar configurations using JNDI when connecting to our old WebSphere servers and did not see this issue.
I was wondering if anyone has experienced this issue before and has any resolution. Really trying to narrow down whether it whether there is incompatibility with this client rerouting HADR failover on Tomcat servers.
本文标签: spring bootTomcat causing issues with DB2 LUW Driver ConfigurationStack Overflow
版权声明:本文标题:spring boot - Tomcat causing issues with DB2 LUW Driver Configuration - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741476619a2380922.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论