I have to do the following:
1.- Read some rows from DB (could be more than 1).
2.- Fill an ArrayList with the data.
3.- Invoke WebService with the data one row at a time.
4.- If there is a problem on the transmission of any row, try 3 more times.
The problem is that I am using a For Each Loop to set the data and I don't know If I can repeat an iteration on that loop.
I was thinking about using the regular For Loop as explained in:
How does the Java 'for each' loop work?
But i have 2 issues with that:
How can I get the right way to get the "length" in my case?
Where I have to use the brackets [i] in my case?
Should I rearrange the code?
This is a brief of my code:
ArrayList<SomeBean> v = new ArrayList<SomeBean>();
while(index < 1000)
{
//Read some data from DB
//Fill the arraylist
for(SomeBean s : v)
{
if (repeat == 0)
{
//Use the Data of the current iteration to invoke Webservice
String column1 = s.getColumn1();
String column2 = s.getColumn2();
String column3 = s.getColumn3();
...
}
else
{
//Don´t use the Data of current iteration, try again with the same data
}
try
{
//Invoke WebService and send the data
if (answer == OK)
{
//Print OK
}
else
{
//Print NOT OK
}
}
catch (Exception)
{
//Print the Exception
repeat++;
if (repeat > 3)
{
repeat = 0; //Go to read a new group of data
index++;
}
}
}
}