提问人:Thomas 提问时间:5/26/2023 更新时间:5/26/2023 访问量:156
如何优化 JDBC DB2 自动客户端重新路由 (ACR) 它花费的时间太长
How to optimize JDBC DB2 Automatic client reroute (ACR) it Takes too long
问:
我们在 HADR 集群中有一个 DB2 环境。 Java 应用程序通过 JDBC 连接到数据库。如果发生错误,这应该连接到备份数据库。
此连接大约需要 50 秒
我怎样才能加快速度?
这是我的代码:
public class JDBCDB2Trial {
private static String connectionURL = "jdbc:db2://X.XXX.db2.1:50000/db2";
private static String fieldUserName = "Administrator";
private static String fieldPassword = "XXXXX";
private static String enableClientAffinitiesList ="1";
private static String clientRerouteAlternateServerName ="X.XXX.db2.1,X.XXX.db2.2";
private static String clientRerouteAlternatePortNumber ="50000,50000";
private static String maxRetriesForClientReroute ="1";
private static String retryIntervalForClientReroute ="0";
private static String enableSeamlessFailover ="1";
public static void main(String args[]) {
try {
Driver driver = (Driver) Class.forName("com.ibm.db2.jcc.DB2Driver").newInstance();
DriverManager.registerDriver(driver);
Properties info = new Properties();
info.put("user", fieldUserName);
info.put("password", fieldPassword);
info.put("enableClientAffinitiesList", enableClientAffinitiesList);
info.put("clientRerouteAlternateServerName", clientRerouteAlternateServerName);
info.put("clientRerouteAlternatePortNumber", clientRerouteAlternatePortNumber);
info.put("maxRetriesForClientReroute", maxRetriesForClientReroute);
info.put("retryIntervalForClientReroute", retryIntervalForClientReroute);
info.put("enableSeamlessFailover", enableSeamlessFailover);
System.out.println("Start connection Test ACR");
final long timeStart = System.currentTimeMillis();
Connection theCon = DriverManager.getConnection(connectionURL, info);
final long timeStop = System.currentTimeMillis();
if(theCon != null){
long time = (timeStop - timeStart)/1000;
System.out.println("Connection successful! Needed time: " +time+"Seconds");
}
答: 暂无答案
评论
loginTimeout=5
X.XXX.db2.1
clientRerouteAlternate*
clientRerouteAlternateServerName ="X.XXX.db2.2"
clientRerouteAlternatePortNumber ="50000"
loginTimeout x 2
X.XXX.db2.1