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,