bonsoir
j'ai une base de données a gérer voir consultation ,ajout et suppression
j'ai créer une page consultation.jsp qui sert a consulter la base de données afin d'afficher les données sollicitées a travers un champs inputText et un bouton afficher et voila son code :
le managed bean associé ConsBcn.java est le suivant :
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 <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <f:view> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Consultation BCN</title> </head> body> <h:form> <h1 style="font-size: 30px; font-family: arial; color:blue">CONSULTATION B.C.N</h1> <h:panelGrid columns="3" border="5" style="background-color:Orange"> <h:outputText value="Numero B.C.N"></h:outputText> <h:inputText id="numbcn" value="#{consBcn.numBcn}"></h:inputText> <h:commandButton value="Afficher" type="submit" action="#{consBcn.affiche}"></h:commandButton> </h:panelGrid> </h:form> </body> </f:view> </html>
mais le probleme que rien ne s'affiche
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 package stt; import java.sql.*; import java.util.Date; public class ConsBcn { private int numbcn ; public ConsBcn () {} public void setNumBcn(int numbcn) { this.numbcn=numbcn; } public int getNumBcn() { return numbcn; } public String affiche() { String url ="jdbc:mysql://localhost:3306/transtu"; String user= "root"; String pwd = ""; Date r5 = new Date(); int r3,r4,r6 = 0,r7 = 0; String r1,r2,r8,r9,lm; try { Class.forName("org.gjt.mm.mysql.Driver"); Connection con = DriverManager.getConnection(url,user ,pwd ); Statement stmt = con.createStatement(); ResultSet re = stmt.executeQuery("select * from bcn where n_bcn="+numbcn); while (re.next()) { r1 = re.getString("id_titre");// champ dans la table r2 = re.getString ("serie"); r3 = re.getInt ("n_debut"); r4 = re.getInt("n-fin"); r5 = re.getDate("dt_bcn"); r6 = re.getInt ("cd_art"); r7 = re.getInt ("n_bcn"); r8 = re.getString("cd-dep"); r9 = re.getString("login_createur"); Date dc = re.getDate("date_creation"); lm= re.getString("login_modificateur"); Date dm = re.getDate("date_modification"); } re.close(); stmt.close(); con.close(); } catch (Exception e){System.out.println("Attention"+""+e+"est arrive");} return ("Consultation B.C.N titre de transport: N° bcn ="+r7+"Article="+r6); } }
veuillez m'aider svp et un grand merci pour votre collaboration
Partager