How to connect to 3 different databases and run Queries Parallel through JDBC

你离开我真会死。 提交于 2019-12-20 07:27:38

问题


I have a code where it connects to 3 databases, and runs one query on each database. This is done sequentially.

1) First I have put 3 Queries in a property file.

2) I iterate the Property file and store the Queries in one Array List.

while((propData=reader.readLine())!=null)
{
  /* ....... Iterates the prop file ...... */
}

I have stored the query which I got from Property file in one Array List.

ArrayList<String> list = new ArrayList<String>();

Then I iterated over the list, get each Query , Run it and store the results.

for(int i=0;i<list.size();i++){

String ProcessedRecord = list.get(i);
String app_name = application.get(i);

ResultSet feedDetails = runQuery(ProcessedRecord,app_name); 

while(feedDetails.next()) 
{
  /* ...... */
}

} // End of For Loop

But I want to do this Parallely. Meaning I want to connect to all three different databases parallelly, run the Queries individually on respective database, and bring in the Result Set.

Please help me with the code , how to do it ?

Thanks,

来源:https://stackoverflow.com/questions/37811698/how-to-connect-to-3-different-databases-and-run-queries-parallel-through-jdbc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!