Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JDBC MySQL连接到故障转移节点的速度非常慢_Java_Mysql_Performance_Jdbc_Failover - Fatal编程技术网

Java JDBC MySQL连接到故障转移节点的速度非常慢

Java JDBC MySQL连接到故障转移节点的速度非常慢,java,mysql,performance,jdbc,failover,Java,Mysql,Performance,Jdbc,Failover,我的环境有2台MySQL服务器(INS1和INS2),当我测试故障切换模式时,INS1关闭,驱动程序创建到INS2的连接,连接速度非常慢(Glassfish连接池上也出现过这种情况) 如何优化jdbc属性 运行:当INS1运行时。信息:连接时间为350毫秒 信息:连接时间为16毫秒 信息:15毫秒后连接 信息:连接时间为17毫秒 信息:15毫秒后连接 信息:连接时间为16毫秒构建成功(总时间:0秒) 运行:当INS1关闭时。信息:连接时间为1380毫秒 信息:连接时间为1060毫秒 信息:连接时

我的环境有2台MySQL服务器(INS1和INS2),当我测试故障切换模式时,INS1关闭,驱动程序创建到INS2的连接,连接速度非常慢(Glassfish连接池上也出现过这种情况)

如何优化jdbc属性

运行:当INS1运行时。信息:连接时间为350毫秒

信息:连接时间为16毫秒

信息:15毫秒后连接

信息:连接时间为17毫秒

信息:15毫秒后连接

信息:连接时间为16毫秒构建成功(总时间:0秒)

运行:当INS1关闭时。信息:连接时间为1380毫秒

信息:连接时间为1060毫秒

信息:连接时间为1058毫秒

信息:连接时间为1060毫秒

信息:连接时间为1055毫秒

信息:连接1041毫秒构建成功(总时间:6秒)


//套接字连接超时(以毫秒为单位),0表示无超时。仅适用于JDK-1.4或更新版本。默认值为“0”。
道具放置(“连接超时”,“100”)

是的,我在发帖后找到了。奥尔兹
final String connstr = "jdbc:mysql://INS1,INS2:3306/mysql";
Properties props = new Properties();
props.put("user", "xxx");
props.put("password", "xxx");
props.put("failOverReadOnly", "false");
props.put("roundRobinLoadBalance", "false");

return DriverManager.getConnection(connstr, props);