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

Composants Java Discussion :

[JComboBox] Erreur lors de la recupération d'une valeur


Sujet :

Composants Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    70
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 70
    Par défaut [JComboBox] Erreur lors de la recupération d'une valeur
    je suis sur le point de la finalisation de mon projet en fait il me reste juste la programmation de deux bouton (enregister et créer)

    enregistrer c'est pour enregistrer une modification effectuées sur l'interface graphique d'intervention alors le bouton Creer c'est pour creer une nouvelle intervention

    bon mon problème c'est que ni la requete de la modification ni la création d'une nouvelle intervention ne se s'exécute; je soupçonne les JCombobox puisque j'ai deux Jcombobx (Mpay:mode de paiement et Stat: Statut ) dans ces deux requete et j'ai d'autre requete sans JCombobox qui fonctionne super bien.

    je vous laisse le code des deux classe (modification et création) au cas ou si vous reperez l'erreur

    merci encore une fois
    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
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
     
    Modification
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.text.ParseException;
    import javax.swing.JFormattedTextField;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.text.MaskFormatter;
    public class Finterventionintermodify extends JFrame {      private static final long serialVersionUID = 1L;
        public Finterventionintermodify(){      //Définit une taille pour celle-ci ;
            ici, 400 px de large et 500 px de haut   this.setSize(1280, 770);
            //Nous allons maintenant dire à notre objet de se positionner au centre   this.setLocationRelativeTo(null);
            //Instanciation d'un objet JPanel   JPanel pan = new JPanel();
            //Définition de sa couleur de fond   pan.setBackground(Color.white);
            //On prévient notre JFrame que pan ça sera notre JPanel (contentPane)   this.setContentPane(pan);
            setLayout(null);
            /*   On crée un panal (conteneur) et on lui donne une couleur pourqu'il soit lisible    On déclare de panel comme panel principal    On Crée un label   On ajoute ce label au panel    On défini un layoutManager (FlowLayout)   On attache le layoutManager au panel   */         JLabel Titre=new JLabel(" Fiche d'Intervention Interne ");
            Titre.setFont(new Font("TimesRoman", Font.BOLD, 40));
            Titre.setForeground(Color.red);
            Titre.setBounds(400,50,700,35);
            pan.add(Titre);
            JLabel Ninterinter = new JLabel("N° d'intervention : ");
            Ninterinter.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Ninterinter.setForeground(Color.red);
            Ninterinter.setBounds(100,150,300,25);
            pan.add(Ninterinter);
            final JLabel Ninter = new JLabel(Interventioninter.Nveninter);
            Ninter.setFont(new Font("TimesRoman", Font.BOLD, 20));
            Ninter.setForeground(Color.red);
            Ninter.setBounds(360,155,200,20);
            pan.add(Ninter);
            JLabel Prob = new JLabel("Problématique : ");
            Prob.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Prob.setForeground(Color.red);
            Prob.setBounds(100,230,300,25);
            pan.add(Prob);
            final JTextField Pb = new JTextField(Interventioninter.Pveninter);
            Pb.setBounds(360,235,200,20);
            pan.add(Pb);
            JLabel cout = new JLabel("Coût : ");
            cout.setFont(new Font("TimesRoman", Font.BOLD, 25));
            cout.setForeground(Color.red);
            cout.setBounds(100,310,300,25);
            pan.add(cout);
            final JTextField Ct = new JTextField(Interventioninter.Cveninter);
            Ct.setBounds(360,315,200,20);
            pan.add(Ct);
            JLabel date1 = new JLabel("Date d'entrée : ");
            date1.setFont(new Font("TimesRoman", Font.BOLD, 25));
            date1.setForeground(Color.red);
            date1.setBounds(770,150,300,25);
            pan.add(date1);
            final JLabel Denter = new JLabel(Interventioninter.Dentreinter);
            Denter.setFont(new Font("TimesRoman", Font.BOLD, 20));
            Denter.setForeground(Color.red);
            Denter.setBounds(1030,155,200,20);
            pan.add(Denter);
            /*   try{  MaskFormatter Date1 = new MaskFormatter("##-##-####");
                Date1.setValidCharacters("0123456789");
                Date1.install(Denter);
                Denter.setBounds(1030,155,200,20);
                pan.add(Denter);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            */      JLabel Dinter = new JLabel("Date d'intervention : ");
            Dinter.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dinter.setForeground(Color.red);
            Dinter.setBounds(770,230,300,25);
            pan.add(Dinter);
            final JFormattedTextField Dateinter = new JFormattedTextField(Interventioninter.Dinterveninter );
            Dateinter.setBounds(1030,235,200,20);
            pan.add(Dateinter);
            /*   try{   MaskFormatter Date2 = new MaskFormatter("##-##-####");
                Date2.setValidCharacters("0123456789");
                Date2.install(Dateinter);
                Dateinter.setBounds(1030,235,200,20);
                pan.add(Dateinter);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            */        JLabel Dfac = new JLabel("Date de facturation : ");
            Dfac.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dfac.setForeground(Color.red);
            Dfac.setBounds(770,310,300,25);
            pan.add(Dfac);
            final JFormattedTextField Dfacture = new JFormattedTextField(Interventioninter.Dfacturinter);
            Dfacture.setBounds(1030,315,200,20);
            pan.add(Dfacture);
            /*    try{  MaskFormatter Date3 = new MaskFormatter("##-##-####");
                Date3.setValidCharacters("0123456789");
                Date3.install(Dfacture);
                Dfacture.setBounds(1030,315,200,20);
                pan.add(Dfacture);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            */      JLabel Dsor = new JLabel("Date de sortie : ");
            Dsor.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dsor.setForeground(Color.red);
            Dsor.setBounds(100,390,300,25);
            pan.add(Dsor);
            final JFormattedTextField Dsortie = new JFormattedTextField(Interventioninter.Dsorinter);
            Dsortie.setBounds(360,395,200,20);
            pan.add(Dsortie);
            /*  try{  MaskFormatter Date4 = new MaskFormatter("##-##-####");
                Date4.setValidCharacters("0123456789");
                Date4.install(Dsortie);
                Dsortie.setBounds(360,395,200,20);
                pan.add(Dsortie);
            }
            catch(ParseException e){  e.printStackTrace();
            }
            */  JLabel Description = new JLabel("Description  : ");
            Description.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Description.setForeground(Color.red);
            Description.setBounds(100,470,250,25);
            pan.add(Description);
            final TextArea Descrip = new TextArea(Interventioninter.Descripinter);
            Descrip.setBounds(360,475,870,50);
            pan.add(Descrip);
            JLabel ModP = new JLabel("Mode de paiement : ");
            ModP.setFont(new Font("TimesRoman", Font.BOLD, 25));
            ModP.setForeground(Color.red);
            ModP.setBounds(100,550,300,25);
            pan.add(ModP);
            final JComboBox Mpay = new JComboBox();
            Mpay.addItem("Espèce");
            Mpay.addItem("Carte Bancaire");
            Mpay.addItem("Chèque");
            Mpay.setBounds(360,555,200,23);
            pan.add(Mpay);
            JLabel Statut = new JLabel("Statut : ");
            Statut.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Statut.setForeground(Color.red);
            Statut.setBounds(770,550,300,25);
            pan.add(Statut);
            final JComboBox Stat = new JComboBox();
            Stat.addItem("En cours");
            Stat.addItem("En attente");
            Stat.addItem("Invalide");
            Stat.addItem("Closed");
            Stat.setBounds(1030,555,200,23);
            pan.add(Stat);
            JButton Save = new JButton("Enregistrer");
            Save.setBounds(583,620,170,25);
            pan.add(Save);
            Save.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e) {   // Cette méthode ne sera appelée que pour les évènements sur le bouton monBouton.      // chaine de connexion  final String url = "jdbc:odbc:dbrescue";
                    Connection con = null;
                    Statement requete = null;
                    ResultSet resultat1 = null;
                    try {  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                        con = DriverManager.getConnection(url,"","");
                        requete = con.createStatement();
                        int resultat = requete.executeUpdate("update Interventioninter set DATE_ENTREE='"+Denter.getText()+"', DATE_INTERINT='"+Dateinter.getText()+"', DATE_FACTURATION='"+Dfacture.getText()+"', DATE_SORTIE= '"+Dsortie.getText()+"', PROBLEMATIQUE='"+Pb.getText()+"', DESCRIPTION='"+Descrip.getText()+"', COUT='"+Ct.getText()+"', MODE_PAIEMENT= '"+Mpay.getSelectedItem()+"', INTSTATUT= '"+Stat.getSelectedItem()+"' from Interventioninter where N_INTERINT ="+Interventioninter.Nveninter+" ");
                        JOptionPane.showMessageDialog(null,"Votre intervention a été bien modifiée" );
                        // Labeltest.setText(Numclient+ Nomclient + Ntelclient);
                        Fclient Fclient = new Fclient();
                        Fclient.setVisible(true);
                        dispose();
                    }
                    catch (ClassNotFoundException e1) {  // TODO Auto-generated catch block  e1.printStackTrace();
                    }
                    catch (SQLException e2) {  // TODO Auto-generated catch block  e2.printStackTrace();
                    }
                    catch (Exception e3) {  e3.printStackTrace();
                    }
                    finally {   try {con.close();
                            requete.close();
                            resultat1.close();
                        }
                        catch(final SQLException e1) {e1.printStackTrace();
                        }
                    }
                }
            }
            );
            JButton Anl = new JButton("Annuler");
            Anl.setBounds(583,660,170,25);
            pan.add(Anl);
            Anl.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e) {        Finterventioninter Finterventioninter=new Finterventioninter();
                    dispose();
                }
            }
            );
            //Ferme-toi lorsqu'on clique sur "Fermer" !   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // mettre la fenetre visible    this.setVisible(true);
        }
    }


    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
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
     
     
    Nouvelle
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.text.ParseException;
    import javax.swing.JFormattedTextField;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.text.MaskFormatter;
    public class Newfinterventioninter extends JFrame {      private static final long serialVersionUID = 1L;
        JTextField Pb=null;
        JTextField Ct=null;
        JFormattedTextField Denter=null;
        JFormattedTextField Dateinter=null;
        JFormattedTextField Dfacture =null;
        JFormattedTextField Dsortie=null;
        TextArea Descrip=null;
        JComboBox Mpay=null;
        JComboBox Stat=null;
        public Newfinterventioninter(){      //Définit une taille pour celle-ci ;
            ici, 400 px de large et 500 px de haut   this.setSize(1280, 770);
            //Nous allons maintenant dire à notre objet de se positionner au centre   this.setLocationRelativeTo(null);
            //Instanciation d'un objet JPanel   JPanel pan = new JPanel();
            //Définition de sa couleur de fond   pan.setBackground(Color.white);
            //On prévient notre JFrame que pan ça sera notre JPanel (contentPane)   this.setContentPane(pan);
            setLayout(null);
            JLabel Titre=new JLabel(" Fiche d'Intervention Interne ");
            Titre.setFont(new Font("TimesRoman", Font.BOLD, 40));
            Titre.setForeground(Color.red);
            Titre.setBounds(400,50,700,35);
            pan.add(Titre);
            JLabel Ninterinter = new JLabel("N° d'intervention : ");
            Ninterinter.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Ninterinter.setForeground(Color.red);
            Ninterinter.setBounds(100,150,300,25);
            pan.add(Ninterinter);
            JTextField Ninter = new JTextField();
            Ninter.setBounds(360,155,200,20);
            pan.add(Ninter);
            JLabel Prob = new JLabel("Problématique : ");
            Prob.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Prob.setForeground(Color.red);
            Prob.setBounds(100,230,300,25);
            pan.add(Prob);
            JTextField Pb = new JTextField();
            Pb.setBounds(360,235,200,20);
            pan.add(Pb);
            JLabel cout = new JLabel("Coût : ");
            cout.setFont(new Font("TimesRoman", Font.BOLD, 25));
            cout.setForeground(Color.red);
            cout.setBounds(100,310,300,25);
            pan.add(cout);
            JTextField Ct = new JTextField();
            Ct.setBounds(360,315,200,20);
            pan.add(Ct);
            JLabel date1 = new JLabel("Date d'entrée : ");
            date1.setFont(new Font("TimesRoman", Font.BOLD, 25));
            date1.setForeground(Color.red);
            date1.setBounds(770,150,300,25);
            pan.add(date1);
            final JFormattedTextField Denter = new JFormattedTextField();
            try{  MaskFormatter Date1 = new MaskFormatter("##-##-####");
                Date1.setValidCharacters("0123456789");
                Date1.install(Denter);
                Denter.setBounds(1030,155,200,20);
                pan.add(Denter);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            JLabel Dinter = new JLabel("Date d'intervention : ");
            Dinter.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dinter.setForeground(Color.red);
            Dinter.setBounds(770,230,300,25);
            pan.add(Dinter);
            final JFormattedTextField Dateinter = new JFormattedTextField();
            try{   MaskFormatter Date2 = new MaskFormatter("##-##-####");
                Date2.setValidCharacters("0123456789");
                Date2.install(Dateinter);
                Dateinter.setBounds(1030,235,200,20);
                pan.add(Dateinter);
            }
            catch(ParseException e){  e.printStackTrace();
            }
            JLabel Dfac = new JLabel("Date de facturation : ");
            Dfac.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dfac.setForeground(Color.red);
            Dfac.setBounds(770,310,300,25);
            pan.add(Dfac);
            final JFormattedTextField Dfacture = new JFormattedTextField();
            try{  MaskFormatter Date3 = new MaskFormatter("##-##-####");
                Date3.setValidCharacters("0123456789");
                Date3.install(Dfacture);
                Dfacture.setBounds(1030,315,200,20);
                pan.add(Dfacture);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            JLabel Dsor = new JLabel("Date de sortie  : ");
            Dsor.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Dsor.setForeground(Color.red);
            Dsor.setBounds(100,390,300,25);
            pan.add(Dsor);
            final JFormattedTextField Dsortie = new JFormattedTextField();
            try{  MaskFormatter Date4 = new MaskFormatter("##-##-####");
                Date4.setValidCharacters("0123456789");
                Date4.install(Dsortie);
                Dsortie.setBounds(360,395,200,20);
                pan.add(Dsortie);
            }
            catch(ParseException e){   e.printStackTrace();
            }
            JLabel Description = new JLabel("Description  : ");
            Description.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Description.setForeground(Color.red);
            Description.setBounds(100,470,250,25);
            pan.add(Description);
            final TextArea Descrip = new TextArea();
            Descrip.setBounds(360,475,870,50);
            pan.add(Descrip);
            JLabel ModP = new JLabel("Mode de paiement : ");
            ModP.setFont(new Font("TimesRoman", Font.BOLD, 25));
            ModP.setForeground(Color.red);
            ModP.setBounds(100,550,300,25);
            pan.add(ModP);
            final JComboBox Mpay = new JComboBox();
            Mpay.addItem("Espèce");
            Mpay.addItem("Chèque");
            Mpay.addItem("Carte Bancaire");
            Mpay.setBounds(360,555,200,23);
            pan.add(Mpay);
            JLabel Statut = new JLabel("Statut : ");
            Statut.setFont(new Font("TimesRoman", Font.BOLD, 25));
            Statut.setForeground(Color.red);
            Statut.setBounds(770,550,300,25);
            pan.add(Statut);
            final JComboBox Stat = new JComboBox();
            Stat.addItem("En attente");
            Stat.addItem("En cours");
            Stat.addItem("Closed");
            Stat.addItem("Invalide");
            Stat.setBounds(1030,555,200,23);
            pan.add(Stat);
            JButton create = new JButton(" Créer  ");
            create.setBounds(583,620,170,25);
            pan.add(create);
            create.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e) {   final String url = "jdbc:odbc:dbrescue";
                    Connection con = null;
                    Statement requete = null;
                    try {  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                        con = DriverManager.getConnection(url,"","");
                        requete = con.createStatement();
                        int resultat = requete.executeUpdate("insert into Interventioninter (DATE_ENTREE, DATE_INTERINT, DATE_FACTURATION, DATE_SORTIE, PROBLEMATIQUE, DESCRIPTION, COUT, MODE_PAIEMENT, INTSTATUT, N_CLIENT) values ('"+Denter.getText()+"', '"+Dateinter.getText()+"', '"+Dfacture.getText()+"', "+Dsortie.getText()+", "+Descrip.getText()+", '"+Mpay.getSelectedItem()+"', '"+Stat.getSelectedItem()+"') where N_CLIENT="+Rclient.Nmclient+" ");
                        JOptionPane.showMessageDialog(null,"Utilisateur crée avec succes" );
                        Rclient Rclient = new Rclient();
                        Rclient.setVisible(true);
                        dispose();
                    }
                    catch (ClassNotFoundException e1) {  // TODO Auto-generated catch block  e1.printStackTrace();
                    }
                    catch (SQLException e2) {  // TODO Auto-generated catch block  e2.printStackTrace();
                    }
                    catch (Exception e3) {  e3.printStackTrace();
                    }
                    finally {   try {con.close();
                            requete.close();
                        }
                        catch(final SQLException e1) {e1.printStackTrace();
                        }
                    }
                }
            }
            );
            JButton Anl = new JButton(" Annuler  ");
            Anl.setBounds(583,660,170,25);
            pan.add(Anl);
            Anl.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e) {       Interventioninter Interventioninter = new Interventioninter();
                    dispose();
                }
            }
            );
            //Ferme-toi lorsqu'on clique sur "Fermer" !   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            // mettre la fenetre visible    this.setVisible(true);
        }
    }

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    342
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 342
    Par défaut
    salut,

    euh balises CODE stp

    et tu peut nous mettre que les parties de ton code que tu soupçonne de posé problème stp

    Merci d'avance

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    70
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 70
    Par défaut
    Salut

    désolé j'ai pas fait attention
    bon la partie que je soupçonne pour la classe de modification c'est celle du bouton enregistrer précisement la requete SQL

  4. #4
    Membre Expert
    Avatar de slim_java
    Homme Profil pro
    Enseignant
    Inscrit en
    Septembre 2008
    Messages
    2 272
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Septembre 2008
    Messages : 2 272
    Par défaut
    Citation Envoyé par patriot Voir le message
    mon problème c'est que ni la requete de la modification ni la création d'une nouvelle intervention ne se s'exécute;
    peux tu donner le strakTrace ?

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    70
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 70
    Par défaut
    Salut

    je suis désolé je suis encore debutant en java alors je comprend pas qu'est tu veux dire par strakTrace

    merci

  6. #6
    Membre Expert
    Avatar de slim_java
    Homme Profil pro
    Enseignant
    Inscrit en
    Septembre 2008
    Messages
    2 272
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Septembre 2008
    Messages : 2 272
    Par défaut
    Citation Envoyé par patriot Voir le message
    qu'est tu veux dire par strakTrace
    Dans chaque bloc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    try
    {
    }
     catch ( ...... e)
    {
     e.printStackTrace();
    }
    tu mets un e.printStackTrace() dans la partie catch et tu récupère la trace de l'erreur .on a besoin de connaitre ces traces pour pouvoir te répondre

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    70
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 70
    Par défaut
    Salut

    comme je te disais moi je suis pas si fort en java alors tous ce qui est exception je l'ai copier coller d'une autre classe ou un code similaire d'enregistrement fonctionne. je te laisse le code qui fonctionne en précisant que la seule diifrence entre les deux code que un contient deux Jcombobx(listes déroulantes) et l'autre non.

    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
    Save.addActionListener(new ActionListener() {   public void actionPerformed(ActionEvent e) {     final String url = "jdbc:odbc:dbrescue";
            Connection con = null;
            Statement requete = null;
            try {   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                con = DriverManager.getConnection(url,"","");
                requete = con.createStatement();
                int resultat = requete.executeUpdate("update Client set NOM='"+Nomc.getText()+"', PRENOM='"+Prec.getText()+"', ADRESSE='"+Adress.getText()+"', N_TELFIXE= '"+Ntel.getText()+"', N_TELMOBILE= '"+Ntelm.getText()+"', EMAIL='"+Email.getText()+"' where N_CLIENT="+Nclient.getText()+"");
                JOptionPane.showMessageDialog(null,"Votre compte a été bien modifié" );
                Rclient Rclient = new Rclient();
                Rclient.setVisible(true);
                dispose();
            }
            catch (ClassNotFoundException e1) {   // TODO Auto-generated catch block   e1.printStackTrace();
            }
            catch (SQLException e2) {   // TODO Auto-generated catch block   e2.printStackTrace();
            }
            catch (Exception e3) {   e3.printStackTrace();
            }
            finally {   try {con.close();
                    requete.close();
                }
                catch(final SQLException e1) {e1.printStackTrace();
                }
            }
        }
    }
    );

  8. #8
    Membre Expert
    Avatar de slim_java
    Homme Profil pro
    Enseignant
    Inscrit en
    Septembre 2008
    Messages
    2 272
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 41
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Septembre 2008
    Messages : 2 272
    Par défaut
    Difficile de t'aider sans la trace d'erreur
    Faut que tu sache que
    la méthode d'un JComboBox retourne un Object et non un String

    aussi, je t'invite à vérifier tes requête car si on prend la classe Newfinterventioninter, Dsortie et Descrip sont des JTextField, donc si tu fais
    ca va retourner un String, hors dans ta reqéte tu fais .. il faut donc faire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    '"+Dsortie.getText()+"'
    méme chose pour .
    Vérifie bien tes requêtes sinon tu peux utiliser la classe PreparedStatement

Discussions similaires

  1. [MySQL] erreur lors de l'insertion d'une valeur obtenue par la fonction php mysql_insert_id() !
    Par mourad_betelgeuse dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 04/05/2013, 20h26
  2. Réponses: 6
    Dernier message: 22/01/2011, 01h42
  3. [vb.net] erreur lors de l'éxécution d'une classe
    Par os_rasta dans le forum VB.NET
    Réponses: 10
    Dernier message: 01/12/2005, 18h34
  4. Erreur lors de l'ajout d'une table
    Par FredMines dans le forum SQL Procédural
    Réponses: 1
    Dernier message: 27/07/2005, 13h13
  5. message d'erreur lors de la création d'une base
    Par franculo_caoulene dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 16/04/2004, 15h47

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