salut tous le monde
je veux faire une application web avec struts et j'ai un problem de recuperation des information enregistré dans la base de donnée MySQL
c'est la methode DAO pour faire la connection et executer la requette :
et j'utlise dans mon page de recuperation JSP :
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 public Huile loadConsultDAO(Vehicule v,String affectation,String materiel) throws SQLException { Connection con = null; Statement stmt = null; ResultSet rs = null; String query = "SELECT prix FROM HUILE WHERE matricule = (SELECT matricule FROM VEHICULE WHERE affectation='" +affectation +"' and materiel='" +materiel +"');" ; try { con = dataSource.getConnection(); stmt = con.createStatement(); rs = stmt.executeQuery(query); //List<Vehicule> depenses = v.getDepenses(); // récupère la liste des notes de l'étudiant // efface tous les List<Huile> huile = v.getHuile(); // récupère la liste des notes de l'étudiant huile.clear(); // rs = stmt.executeQuery(query); rs = stmt.executeQuery(query); if (rs.next()) { return new Huile(rs.getString(1),rs.getString(2),rs.getDouble(3),rs.getDouble(4)); } // efface tous les éléments de la liste // while (rs.next()) { // huile.add(new Huile(affectation , materiel , rs.getDouble(3))); else { return null; } } finally { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (con != null) { con.close(); } } }
el la formulaire :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <% for (Huile n : vehicule) {%> <tr> <td><%=n.getPrix() %></td> </tr> <% } %>
merci
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 <tr> <td>Affectation</td> <td> <html:select property="affectation"> <html:option value="Djerba"></html:option> <html:option value="Hammamet"></html:option> <html:option value="Monastir"></html:option> <html:option value="Touzer"></html:option> </html:select></td> <td></td> <td></td> </tr> <tr> <td>Type de Materiel</td> <td><html:select property="materiel"> <html:option value="Bus"></html:option> <html:option value="MiniBus"></html:option> <html:option value="Car"></html:option> <html:option value="4*4"></html:option> </html:select></td> <td></td>
Partager