Jump to content

Please Help Me On Java


Recommended Posts

Posted

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.

Posted

write you method in a class and extend that class to 'TimerTask' class ...

 

 

 

 

Posted

neku edi nachuthe ade fix ayipo

babe just in ?

 

or 

 

justinbabe?

 

Posted

write you method in a class and extend that class to 'TimerTask' class ...

+1

Posted

ejb 3.1 aithy simple gaa @schedule annoation use cheyi ... thats it 

Posted

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 ...

 

Posted

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
    );
  }
}
Posted

pyna code on the fly rasa .. didn't run it and check ... nuvvu try cheyyi .. errors vasthe plz paste your code and lets evaluate .. 

Posted

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
    );
  }
}

 

Posted

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 :)

×
×
  • Create New...