IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Servlets/JSP Java Discussion :

Modification dans la base de données


Sujet :

Servlets/JSP Java

  1. #1
    Futur Membre du Club
    Inscrit en
    Mars 2008
    Messages
    9
    Détails du profil
    Informations forums :
    Inscription : Mars 2008
    Messages : 9
    Points : 5
    Points
    5
    Par défaut Modification dans la base de données
    salut à tous ,
    j'utilise des beans pour faire des mise a jour dans la base de données,l'ajout et la suppression marchent bien mais la modifications me pose un probleme

    voici mon code de ma liste qui contient les information sur mes champs:
    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
     
     
    <%@ page errorPage = "/WEB-INF/erreur.jsp" import="bd.*" %>
     
    <html>
      <head><title>Fournisseur</title></head>
      <body background="D:\u.jpg">
        <font face="Arial">
            <h2 align="center">Fournisseur</h2>
            <hr>
            <table bgcolor="1" cellpadding="3" cellspacing="2" width="90%" align="center">
                <tr bgcolor="yellow">
                    <th align="left"><a href="bienvenue.jsp">Liste_Fournisseur</th>
                    <th align="right">
                        <a href="nouvelfournisseur.jsp">Ajouter_Fournisseur</a>
                    </th>
            </table>
     
      <font face="Arial">
      <p><table border="1" cellpadding="3" cellspacing="2" width="90%" align="center">
     
          <tr bgcolor="#FF6600">
              <th>Id</th>
              <th>Nom</th>
              <th>Code</th>
              <th>Adresse</th>
              <th>Tel</th>
              <th>Fax</th>
              <th>Email</th>
     
         </tr>
         <%   
             ListeFournisseur listeFournisseur = new ListeFournisseur(1);
            int ligne = 0;
             while (listeFournisseur.suivant()) {
         %>
         <% String ide;
         ide= listeFournisseur.idFournisseur();
         %> 
         <tr bgcolor="<%= ligne++ % 2 == 0 ? "#FFFF66" : "#FFCC00" %>">
             <td><%= ide %></td>
             <td><b><%= listeFournisseur.nom() %></b></td>
             <td><%= listeFournisseur.code() %></td>
             <td><%= listeFournisseur.adresse() %></td>
             <td><%= listeFournisseur.tel() %></td>
             <td><%= listeFournisseur.fax() %></td>
             <td><%= listeFournisseur.email() %></td>
             <td><a href="suppression.jsp?id=<%=ide %>">supprimer</td>
             <td><a href="modification1.jsp?id=<%= ide %>">modifier</td>
          </tr>
         <%
             }
             listeFournisseur.arrêt();
         %>
     </table>
     </font>
     
    <%@page import="java.util.Date, java.text.DateFormat" %>
     
    <%!
        DateFormat formatDate = DateFormat.getDateInstance(DateFormat.FULL);
     %> 
            <br><hr>
            <h4 align="right"><%= formatDate.format(new Date()) %></h4>
     
         </font>
       </body>
    </html>
    La je veux lorsque je clique sur le boutton "Modifier" il m'affiche la page ou je vais faire la modification:

    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
     
     
     <%@ page errorPage = "/WEB-INF/erreur.jsp" import="bd.*,java.lang.Integer.*"  %>
     <html>
      <head><title>Gestion Du Stock</title></head>
      <body background="D:\j.jpg">
        <font face="Arial">
            <h2 align="center">Gestion Du Stock</h2>
            <hr>
            <table bgcolor="1" cellpadding="3" cellspacing="2" width="90%" align="center">
                <tr bgcolor="#FF9900">
                    <th align="left"><a href="bienvenue.jsp">Liste_Fournisseur</th>
                    <th align="right">
                        <a href="nouvelfournisseur.jsp">Ajouter_Fournisseur</a>
                    </th>
            </table>
     
      <jsp:useBean id="utilisateur" class="bd.Fournisseur">
          <jsp:setProperty name="utilisateur" property="*" />
     
          <p><table border="1" cellpadding="3" cellspacing="2" width="90%" align="center">
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Nom</b></td>
                 <td><jsp:getProperty name="utilisateur" property="nom"  /></td>
             </tr>
     
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Code</b></td>
                 <td><jsp:getProperty name="utilisateur" property="code"  /></td>
             </tr> 
     
     
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Adresse</b></td>
                 <td><jsp:getProperty name="utilisateur" property="adresse"  /></td>
             </tr>
     
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Tel</b></td>
                 <td><jsp:getProperty name="utilisateur" property="tel"  /></td>
             </tr> 
     
     
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Fax</b></td>
                 <td><jsp:getProperty name="utilisateur" property="fax"  /></td>
             </tr>
     
             <tr>
                 <td bgcolor="#FF9900" width="100"><b>Email</b></td>
                 <td><jsp:getProperty name="utilisateur" property="email"  /></td>
             </tr>                          
         </table>                         
     
          <p>
         <h3 align="center">
     
         <%
         Integer ide;
            ide =Integer.parseInt(request.getParameter("id").toString());
            utilisateur.modifier(ide);
         %>
          <font color="red">Modifier votre Founisseur</font>   
         </h3>
     </jsp:useBean>
     
    <%@page import="java.util.Date,java.text.DateFormat" %>
     
    <%!DateFormat formatDate = DateFormat.getDateInstance(DateFormat.FULL);%> 
            <br><hr>
            <h4 align="right"><%=formatDate.format(new Date())%></h4>
         </font>
       </body>
    </html>
    La c la methode qui j'ai mis dans ma classe bean:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
     
     public int modifier(int id){
            	  miseAJour("update Fournisseur set nom='"+nom+"' , code='"+code+"' , adresse='"+adresse+"' , tel='"+tel+"' , fax='"+fax+"' , email='"+email+"' WHERE id='"+id+"'" );
            	  return 1;
              }
    lorsque j clique sur le button "modifier" il me donne vraiment les champs et il lui donne des valeur null et je peut pas les modifier.
    SVP Que je doit mettre dans la page JSP "moddification1.jsp",pour qu'il me donne la possiblité de modifier?

  2. #2
    Membre averti Avatar de florentB
    Homme Profil pro
    Développeur Java
    Inscrit en
    Décembre 2006
    Messages
    332
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Décembre 2006
    Messages : 332
    Points : 441
    Points
    441
    Par défaut
    De mémoire, le Integer.parseInt n'est pas au top.
    Essai un
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    new Integer(taVariable)

Discussions similaires

  1. Mise à jour du Dataset après modification dans la base de donnée
    Par Ravens dans le forum Développement Windows
    Réponses: 7
    Dernier message: 03/06/2013, 22h01
  2. Réponses: 5
    Dernier message: 20/09/2011, 18h55
  3. [Postgres] Aucune modification dans la base de données
    Par Myriouma dans le forum Hibernate
    Réponses: 7
    Dernier message: 30/07/2010, 15h52
  4. Réponses: 1
    Dernier message: 29/04/2009, 17h22
  5. Réponses: 1
    Dernier message: 29/04/2008, 10h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo