dcsimg
Servlet deleting web folders & DB2 data.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rupali_kandarkar
Posted On:   Friday, March 14, 2003 03:44 PM

I have a servlet that has to perform the following tasks:

1. Identify expired records from DB2 table.

2. Delete related web folders.

3. Delete expired DB2 records.


Please advice how the design should be:

If there are 5 expired records then should I first delete all the related web folders and then DB2 records or vice versa or have a loop where in first I delete one web folder then related DB2, then next record ......delete web folder then DB2. And so on..........


Thanks for your help.

Re: Servlet deleting web folders & DB2 data.

Posted By:   Viral_Shah  
Posted On:   Thursday, March 20, 2003 04:50 AM

rupali,



as such, there cannot be a standard-common way of designing your application, as every application is different.. at the most we can take help of some design patters..



as far as ur problem is concerned, IMHO, the last option you suggested is the best approach.. delete an entry from the db and then delete an entry from the file-system.. repeating the same for all the enteries...



ideal way would be... you have a try - catch inside the for loop, which handles every deletion separately.. set the db-connection's auto-commit to false..delete the record from the db.. if that itself throws an exception folder-deletion is not going to be executed at all.. if folder-deletion gives you a IOException, rollback the db as well... this shouold preserve the integrity...



regards,

Viral
About | Sitemap | Contact