Question

I have made a processing tool which is reading data from table. There is large amount of data in the table so all processing is not possible to done at a single time. My problem is when my processing application restarts it starts processing from beginning which I don't want. I want to process from the next row where it stopped its execution.

So my question is: is there any method in Java by which I can record the last row processed and save it into table as soon as my application stops.

No correct solution

OTHER TIPS

You can generate a file where you store the row read each time.

PrintWriter writer = new PrintWriter("table-process", "UTF-8");
writer.println(row);
writer.close();

and When the application starts, you only have to read the value of that file and init the row count.

I don't think their is any method as such.

As the value of last visited row should be known next time when application restarts, so it mean value should be persisted over the time.

May be you can create another table and store the primary key of the last vised row, so when your application restarts it checks matches the primary key and begin its search from their on.

or else their can be other methods like file appending, etc depends on you

Hope it helps.

For the reasons outlined here, consider using java.util.prefs.Preferences to store the needed restart data.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top