daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Jun 22nd, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. webxml:
  2.   <servlet>
  3.         <servlet-name>MyServletContextListener</servlet-name>
  4.         <display-name>Quartz Initializer Servlet</display-name>
  5.         <servlet-class>MyServletContextListener</servlet-class>
  6.         <load-on-startup>1</load-on-startup>
  7.         <init-param>
  8.             <param-name>shutdown-on-unload</param-name>
  9.             <param-value>true</param-value>
  10.         </init-param>
  11.         <init-param>
  12.             <param-name>start-scheduler-on-load</param-name>
  13.             <param-value>true</param-value>
  14.         </init-param>
  15.     </servlet>
  16.  
  17.  
  18. CRON:
  19.  
  20. import org.quartz.CronTrigger;
  21. import org.quartz.JobDetail;
  22. import org.quartz.Scheduler;
  23. import org.quartz.SchedulerFactory;
  24. import org.quartz.impl.StdSchedulerFactory;
  25.  
  26. public class CronScheluder {
  27.  
  28.     public CronScheluder() throws Exception {
  29.  
  30.         try {
  31.         SchedulerFactory sf = new StdSchedulerFactory();
  32.  
  33.         Scheduler sche = sf.getScheduler();
  34.  
  35.         sche.start();
  36.  
  37.         JobDetail jDetail = new JobDetail("Newsletter", "NJob", MyJob.class);
  38.  
  39.         //"0 0 12 * * ?" Fire at 12pm (noon) every day
  40.         //"0/2 * * * * ?" Fire at every 2 seconds every day
  41.  
  42.  CronTrigger crTrigger = new CronTrigger("cronTrigger", "NJob", "0 36 11 * * ?");
  43.  
  44.         sche.scheduleJob(jDetail, crTrigger);
  45.        
  46.         }catch (Exception e) { e.printStackTrace(); }
  47.     }
  48. }
  49.  
  50.  
  51. MyJob.class:
  52.  
  53.  dbFill fillDB = new dbFill();
  54.  
  55. dbFill:
  56.  
  57.  
  58.             URL searchPage = new URL(url_kid);
  59.        
  60.  
  61.        
  62.           Class.forName("com.mysql.jdbc.Driver");
  63.          
  64.          
  65.          
  66.            String urls = "jdbc:mysql://localhost/lekrease_Lekrea";
  67.           Connection conn = DriverManager.getConnection(urls,"_root","root");
  68.          
  69.            Statement str = conn.createStatement();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top