it depends on what your data looks like and how you're doing everything. i assume the server has a DB on it. if everything is an insert, just store the primary keys. then to undo it, just delete the pkids. if you're including updates, then you'll have a difficult time of it.
if you know that you'll have to undo it immediately (eg if it fails), then just handle it via transactions and rollback. if you won't know till much later, i'd store it in another database table or add a column with details for however you're going to determine it needs to be undone. so if you run your program at 8pm and ends at 8:05 and generates 1000 new records, you can store a log that has the starting pkid and ending pkid and the time stamps. assuming nobody else can insert rows at the same time. on the other hand if it includes updates, you'll have to include all the original column values as well as which pkid changed. how to handle it most efficiently really depends on what you're doing.
if your question is specifically stringbuilder vs jsonobjects, then the string builder (or string buffer? whichever isn't thread safe) is likely faster. but that depends on how you go about formatting the data. for example do you already have jsonobjects and you're just gonna call tostring on them? on the other hand if you start with plain data and then you have to jsonify them to create json objects, obv that will take longer.
This post was edited by carteblanche on Nov 4 2013 08:13pm