1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
public class Test {
static int i = 0;
static Timer timer;
static Connection con;
public static void main(String[] args) {
//lancement de la tache périodique
class RemindTask extends TimerTask {
public void run() {
Dns dns = new Dns(@1);
Dns dns2 = new Dns(@2);
Dns dns3 = new Dns(@3);
Vector t=null,t2=null,t3=null;
try {
t = dns.tableau(dns.site());
t2=dns.tableau(dns2.site());
t3=dns.tableau(dns.site());
} catch (IllegalStateException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
try {
double perte=dns.taux(dns.site());
double perte2=dns2.taux(dns2.site());
double perte3=dns3.taux(dns3.site());
} catch (IllegalStateException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
tableau tab = new tableau();
connexionBD con= new connexionBD();
int res6=con.excuteupdate("insert into table1(date,heure,min,moy,max,perte) values (now(),now(),"+tab.minimum(t3)+","+tab.moyenne(t3)+","+tab.maximum(t3)+")");
res7=con.excuteupdate("insert into table2(date,heure,min,moy,max,perte) values (now(),now(),"+tab.minimum(t2)+","+tab.moyenne(t2)+","+tab.maximum(t2)+")");
res8=con.excuteupdate("insert into table3(date,heure,min,moy,max,perte) values (now(),now(),"+tab.minimum(t1)+","+tab.moyenne(t1)+","+tab.maximum(t1)+")");
}
}
timer = new Timer();
timer.scheduleAtFixedRate(new RemindTask(), 0, 1800 * 1000);
}
} |
Partager