[英]Connect multiple MySQL server using JDBC Java
I have 10 different MySQL servers with the same schema design. 我有10个具有相同架构设计的不同MySQL服务器。 Now I have to query each server and merge results in java which is same as UNION ALL
in SQL. 现在,我必须查询每个服务器并在Java中合并结果,这与SQL中的UNION ALL
相同。
All DB servers return the same data format, and I tried sequential call of all server but it takes more time. 所有数据库服务器都返回相同的数据格式,我尝试顺序调用所有服务器,但是这需要更多时间。
How can I speed up the process? 我如何加快这一过程?
Scenario 情境
This probably your sequential logic: 这可能是您的顺序逻辑:
List<YourObject> arr = new ArrayList<YourObject>();
I can think of a solution that might consume less time: 我可以想到一个可能耗时更少的解决方案:
How about this logic: 这个逻辑怎么样:
you can cut the sequential into threads. 您可以将序列切成线程。 each thread will connect to a different server. 每个线程将连接到不同的服务器。 once you have result from a server lock the arr and add the results. 从服务器获得结果后,请锁定arr并添加结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.