BabeJustin11 Posted November 20, 2014 Report Posted November 20, 2014 Hi i have a small requirement in java EJB. should write a method to make db changes and this method should be triggered on a specific day and time.
innovative Posted November 21, 2014 Report Posted November 21, 2014 write you method in a class and extend that class to 'TimerTask' class ...
BabeJustin11 Posted November 21, 2014 Author Report Posted November 21, 2014 neku edi nachuthe ade fix ayipo babe just in ? or justinbabe?
jpismahatma Posted November 21, 2014 Report Posted November 21, 2014 write you method in a class and extend that class to 'TimerTask' class ... +1
ZuniorVentiyar Posted November 21, 2014 Report Posted November 21, 2014 ejb 3.1 aithy simple gaa @schedule annoation use cheyi ... thats it
BabeJustin11 Posted November 21, 2014 Author Report Posted November 21, 2014 theoritical ga ardham ayindi ela cheyalo but practical ga ravatledu ... so do you have any exampless where i can follow them? write you method in a class and extend that class to 'TimerTask' class ...
innovative Posted November 21, 2014 Report Posted November 21, 2014 theoritical ga ardham ayindi ela cheyalo but practical ga ravatledu ... so do you have any exampless where i can follow them? Kinda code snippet choodu .. dhanni modify cheskoni nee req ni saripoynattu rasko ... import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class DbChangesClass extends TimerTask { public void run() { System.out.println("In Db class"); } } class YourApp{ public static void main(String[] args) { Timer t = new Timer(); Calendar cal = Calendar.getInstance(); cal.set ( Calendar.DAY_OF_WEEK, Calendar.THURSDAY ); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); // set up timing as per your requirement here t.schedule( new DbChangesClass(), cal.getTime(), 1000 * 60 * 60 * 24 * 7 ); } }
innovative Posted November 21, 2014 Report Posted November 21, 2014 pyna code on the fly rasa .. didn't run it and check ... nuvvu try cheyyi .. errors vasthe plz paste your code and lets evaluate ..
BabeJustin11 Posted November 21, 2014 Author Report Posted November 21, 2014 Repu try chesta idi implement chesi ! Thanks a lot appreciate it but oka line ardham kaledu ? 1000 * 60 * 60 * 24 * 7 Kinda code snippet choodu .. dhanni modify cheskoni nee req ni saripoynattu rasko ... import java.util.Calendar; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class DbChangesClass extends TimerTask { public void run() { System.out.println("In Db class"); } } class YourApp{ public static void main(String[] args) { Timer t = new Timer(); Calendar cal = Calendar.getInstance(); cal.set ( Calendar.DAY_OF_WEEK, Calendar.THURSDAY ); cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); // set up timing as per your requirement here t.schedule( new DbChangesClass(), cal.getTime(), 1000 * 60 * 60 * 24 * 7 ); } }
innovative Posted November 21, 2014 Report Posted November 21, 2014 Repu try chesta idi implement chesi ! Thanks a lot appreciate it but oka line ardham kaledu ? 1000 * 60 * 60 * 24 * 7 No probs !! date.factors concept adhi .. 7 days of a week ani ardham .. 1000ms * 60sec * 60min * 24hrs * 7 days google date.factors for more information :)
Recommended Posts