Bonjour, j'ai ecrit un petit code en java qui permet le lancement automatique d'un telechargement Http,
une fois ce code executé ici
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 package marouene; import java.io.IOException; import gcp.httpeasy.Http; import gcp.httpeasy.Request; public class HttpClient { /** * @param args * @throws IOException * */ public static double debithttp (String adresse) { Request request = Http.get(adresse); long start = System.currentTimeMillis(); //appel au serveur byte[] response = request.asBytes(); long fin = System.currentTimeMillis(); return (double)response.length / (fin - start); } }
mais ca me genere ces erreurs la (le code est utilisé en linux)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 package marouene; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.text.DecimalFormat; import java.util.Timer; import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.TimerTask; import java.text.*; import java.util.Locale; public class TestPerformance { static int i = 0; static Timer timer; static double[] tableauftp = new double[10]; static double[] tableauhttp = new double[10]; static Connection con; public static void main(String[] args) { class RemindTask extends TimerTask { public void run() { DecimalFormat df = new DecimalFormat("########.00"); TestFtp ftp = new TestFtp(); HttpClient http = new HttpClient(); try { Class.forName("com.mysql.jdbc.Driver"); try { con =DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/newdata","root","root"); } catch (SQLException e) { e.printStackTrace(); } } catch (ClassNotFoundException e) { e.printStackTrace(); } capture cc = new capture(); try { Statement stm=con.createStatement(); int res1=stm.executeUpdate("insert into affichage(heure,ftp) values (now(),"+ftp.calculdebitftp("otn","otnotn","41.228.192.9","/30M")); java.sql.Date sDate = new java.sql.Date(System.currentTimeMillis()); System.out.println(ftp.calculdebitftp("login","mdp","adresse","fichier")); //System.out.println(HttpClient.debithttp("adresse")); //cc.start(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } timer = new Timer(); timer.scheduleAtFixedRate(new RemindTask(), 0, 300 * 1000); } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Exception in thread "Timer-0" java.lang.NoClassDefFoundError: org/apache/http/client/methods/HttpRequestBase at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2406) at java.lang.Class.getConstructor0(Class.java:2716) at java.lang.Class.newInstance0(Class.java:343) at java.lang.Class.newInstance(Class.java:325) at gcp.httpeasy.Http.initHandler(Http.java:41) at gcp.httpeasy.Http.<clinit>(Http.java:35) at marouene.HttpClient.debithttp(HttpClient.java:19) at marouene.TestPerformance$1RemindTask.run(TestPerformance.java:58) at java.util.TimerThread.mainLoop(Timer.java:534) at java.util.TimerThread.run(Timer.java:484) Caused by: java.lang.ClassNotFoundException: org.apache.http.client.methods.HttpRequestBase at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) ... 11 more
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:532) at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) at com.mysql.jdbc.Util.getInstance(Util.java:382) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1664) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1583) at marouene.TestPerformance$1RemindTask.run(TestPerformance.java:55) at java.util.TimerThread.mainLoop(Timer.java:534) at java.util.TimerThread.run(Timer.java:484) com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:532) at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) at com.mysql.jdbc.Util.getInstance(Util.java:382) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1664) at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1583) at marouene.TestPerformance$1RemindTask.run(TestPerformance.java:55) at java.util.TimerThread.mainLoop(Timer.java:534) at java.util.TimerThread.run(Timer.java:484)
Partager