Page 1 of 2 12 LastLast
Results 1 to 20 of 38
  1. #1
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default JtextField and Table MS Access value.

    I try to populate a jTextField (jTxtNomPrenom) with the value of a db Acces fields but nothins appears with the code below.

    what's matter ?

    Java Code:
    public final void FilljTextNomPrenom() {
        try{
    
            String sql1 = "SELECT * FROM Signaletique WHERE Matricule ='"+jTxtNomPrenom+"'";
            ps = conn.prepareStatement(sql1);
            rs = ps.executeQuery();
                   
            while (rs.next()){
                String NomPrenom = rs.getString(3);
           //jTxtNomPrenom.setText(rs.getString(3));
              jTxtNomPrenom.setText(NomPrenom);
              //rs.getString(3);
            }
        }    catch(SQLException e) {
            
            JOptionPane.showMessageDialog(null, e);
        }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: JtextField and Table MS Access value.

    Stick some debugging in there (println statements) printing out values, and where you are in the code.
    That way you can track what's going on.

    For starters, print out the SQL statement before you execute it and then see if it works directly against the database itself.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: JtextField and Table MS Access value.

    You are missing the getText() call to the JTextField. Instead, Java now uses the toString() method of JTextField, which makes your query looks like this: "SELECT * FROM Signaletique WHERE Matricule = 'javax.swing.JTextField[,0,0,0x0,invalid,layout=javax.sw..................]'"

    And you are close, but not quite. If you are using prepared statements, make sure to do it the right way:
    Java Code:
    String sql1 = "SELECT * FROM Signaletique WHERE Matricule =?";
    ps = conn.prepareStatement(sql1);
    ps.setString(1, jTxtNomPrenom.getText());
    rs = ps.executeQuery();
    Last edited by SurfMan; 11-02-2016 at 12:34 PM.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  4. #4
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    I Add many controls but n results.

    Java Code:
    private void jTxtMatrActionPerformed(ActionEvent e) {
        
     try{
    
    String sql1 = "SELECT Nom FROM Signaletique";// WHERE Matricule =?";
    
    
    ps = conn.prepareStatement(sql1);
    ps.setString(3, jTxtNomPrenom.getText());
    rs = ps.executeQuery();
             System.out.println("Nom rs" + jTxtNomPrenom);  
             System.out.println("Nom 0.1" + "Nom"); 
                while (rs.next()){
                //String NomPrenom = rs.getString(3);
                //jTxtNomPrenom.setText(rs.getString(3));
                jTxtNomPrenom.setText("Nom");
                System.out.println("Nom 1" + jTxtNomPrenom); 
                //rs.getString(3);
            }
        }    catch(SQLException ex) {
            
            JOptionPane.showMessageDialog(null, e);
        }
    }
    Last edited by Tolls; 11-02-2016 at 04:09 PM. Reason: Fix tags

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: JtextField and Table MS Access value.

    Does that code even run?
    Your query doesn't match the parameters you are assigning, since you commented out the WHERE clause.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,989
    Rep Power
    8

    Default Re: JtextField and Table MS Access value.

    And it's not parameter 3 but 1. Each question mark represents one parameter you need to set in the PerparedStatement using the set...() methods. The code as is, will compile, but when running, it should complain about a parameter index out of range, or something similar.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  7. #7
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    Hello everybody
    I ve adapted my code but i ve still the same problem> the name doesn tappears into jTxtNomPrenom.

    I use netbeans

    public final void FilljTxtNomPrenom() throws SQLException {
    // JTextField field;

    affiche("Etape 2");
    String sql1 = "SELECT * FROM Signaletique WHERE Matricule =?";
    ps1 = conn.prepareStatement(sql1);
    ps1.setString(1, jTxtNomPrenom.getText());
    rs1 = ps1.executeQuery();
    System.out.println("Nom");
    System.out.println(jTxtNomPrenom);

    ps1.setString(1,jTxtMatr.getText()); // recherche des éléments qui commence par la chaine saisie
    System.out.println(jTxtMatr);
    try {

    ResultSet rs = ps1.executeQuery();
    System.out.println(rs1);
    while ( rs1.next() ) {

    jTxtNomPrenom.setText(rs1.getString(3)+" "+rs1.getString(4));
    affiche("Etape 3");

    System.out.println(rs1.getString(1) +"* \t** "+rs1.getString(2) + rs1.getString(3)+ rs1.getString(4));
    }
    }
    catch (SQLException e ) {
    }

    finally {
    if (rs1 != null) { rs1.close(); }
    }

    {
    JOptionPane.showMessageDialog(null, "Saved !!!!!");
    // conn.close();
    }
    }

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    Be sure to have a call to the printStackTrace() method in all the catch blocks.


    Please Wrap your code in code tags, NOT quote tags.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    The
    Java Code:
    e.printStackTrace();
    are added.
    Same result


    Java Code:
    public final void FilljTxtNomPrenom() throws SQLException {
         //    JTextField field;
    
     affiche("Etape 2");
    String sql1 = "SELECT * FROM Signaletique WHERE Matricule =?";
    ps1 = conn.prepareStatement(sql1);
    ps1.setString(1, jTxtNomPrenom.getText());
    rs1 = ps1.executeQuery();
          System.out.println("Nom");
          System.out.println(jTxtNomPrenom);
    
          ps1.setString(1,jTxtMatr.getText()); // recherche des éléments qui commence par la chaine saisie
              System.out.println(jTxtMatr); 
     try {
         
      ResultSet rs = ps1.executeQuery();
    System.out.println(rs1);
                    while ( rs1.next() ) {
                      
                   jTxtNomPrenom.setText(rs1.getString(3)+" "+rs1.getString(4));
     affiche("Etape 3");
    
    System.out.println(rs1.getString(1) +"* \t** "+rs1.getString(2) + rs1.getString(3)+ rs1.getString(4));
            } 
    } 
     catch (SQLException e ) {
         
         e.printStackTrace();
         }
    
             finally {
            if (rs1 != null) { rs1.close(); }
    }
    
    {  
              JOptionPane.showMessageDialog(null, "Saved !!!!!");
         //       conn.close();
    }  
    }

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    Are any messages shown on the console?
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    There are only controls messages.
    Containing of jTxtNomPrenom =
    Java Code:
    javax.swing.JTextField[,280,40,200x20,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@7b686278,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=0,columnWidth=0,command=,horizontalAlignment=LEADING]
    Java Code:
    debug:
    --- La connection etablie---
    --- La connection etablie---
    Etape 2
    Nom
    javax.swing.JTextField[,280,40,200x20,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@7b686278,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=0,columnWidth=0,command=,horizontalAlignment=LEADING]
    javax.swing.JTextField[,140,90,91x20,layout=javax.swing.plaf.basic.BasicTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0.0,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@7b686278,flags=296,maximumSize=,minimumSize=,preferredSize=,caretColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIResource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],columns=0,columnWidth=0,command=,horizontalAlignment=LEADING]
    net.ucanaccess.jdbc.UcanaccessResultSet@79e0a63
    --- La connection etablie---

  12. #12
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    Where are the print out from line 21 and 23?
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: JtextField and Table MS Access value.

    You're using the same statement object and attempting two result sets.
    You can't do that.
    As soon as you execute the second query the first result set (rs1) is closed.

    You need two statement objects.

    Though I will ask, why are you running two queries?
    You don't even use the second result set.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  14. #14
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    Hello,

    Here is my whole code. Blue begins qt line 21.
    May I ask you why line 21 and 23.

    Can you see something in the error code?

    Thanks for all

    Habiler

    Java Code:
    package decisions;
    
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.event.ActionEvent;
    import java.beans.*;
    import java.sql.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import com.toedter.calendar.*;
    import java.beans.PropertyChangeListener;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.table.DefaultTableModel;
    
    /**
     *
     * @author habiler
     */
    [COLOR="#0000CD"]public class AddDecisionsJFrame1 extends JFrame {
     Connection conn =null;
    ResultSet rs = null;
    ResultSet rs1 = null;
    PreparedStatement ps = null;
    PreparedStatement ps1 = null;
     //    DefaultTableModel md = new DefaultTableModel(); 
    [/COLOR]     
    
         
            public AddDecisionsJFrame1() throws SQLException {
            initComponents();
            conn = Connect.ConnectDB();
            jDateChooserPostposeDebut.setVisible(false);
            jDateChooserPostposeFin.setVisible(false);
            jTextNom_Parent.setVisible(false);
            FilljCboTypeAbsence();
            FilljTxtNomPrenom();
            DefaultTableModel md = new DefaultTableModel(); 
        }
    
    
    
       static Void affiche(String message) {
          System.out.println(message);
         return null;
       }
    
    //   private Object oui;
       
        /**
         * Creates new form DeciiJFrame
         */
    @SuppressWarnings("empty-statement")
        private void jDateChooserDateFinPropertyChange(PropertyChangeEvent e) {
        NullPointerException exp;
                               jDateChooserDateFin.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(java.beans.PropertyChangeEvent evt1) {
                if (evt1.getPropertyName().equals("date")) {
                    if (jDateChooserDateDebut.getCalendar() == null) {
                        JOptionPane.showMessageDialog(null,
                                "La date de début est nulle !!!.",
                                " Avertissement", JOptionPane.WARNING_MESSAGE);;
                    } else
                        
                    {
                        if (jDateChooserDateFin.getCalendar().before(jDateChooserDateDebut.getCalendar()))
                        {
                            JOptionPane.showMessageDialog(null,
                                    "La date de début est "
                                            + "supérieure à la date de fin !!!.",
                                    " Avertissement", JOptionPane.WARNING_MESSAGE);;
                        } else
                          
                        {
                       affiche("bon d'accord ...");
                        }
                    } }
            }
        });   
        }
    
        private void jDateChooserPostposeFinPropertyChange(PropertyChangeEvent e) {
        NullPointerException exp;
         jDateChooserPostposeFin.addPropertyChangeListener(new PropertyChangeListener() {
                      @Override
                      public void propertyChange(java.beans.PropertyChangeEvent evt1) {
                          if (evt1.getPropertyName().equals("date")) {
                              if (jDateChooserPostposeDebut.getCalendar() == null) {
                                  JOptionPane.showMessageDialog(null,
                                          "La date de début est nulle !!!.",
                                          " Avertissement", JOptionPane.WARNING_MESSAGE);;
                              } else {
                                  if (jDateChooserPostposeFin.getCalendar().before(jDateChooserPostposeDebut.getCalendar())) {
                                      JOptionPane.showMessageDialog(null,
                                              "La date de début est inférieure à la date de fin !!!.",
                                              " Avertissement", JOptionPane.WARNING_MESSAGE);;
                                  } else {
                               affiche("bon d'accord ...");
                                  }
                              }
                          }
                      }
                  });
          // TODO add your code here
        }
    
    public final void FilljCboTypeAbsence() {
        
     //   affiche("Etape 1");
        try{
    
            String sql = "SELECT * FROM Typedossier ";
            ps = conn.prepareStatement(sql);
            rs = ps.executeQuery();
            
            
            while (rs.next()){
              jCboTypeAbsence.addItem(rs.getString("Type"));
                
            }
        }    catch(SQLException e) {
            
            JOptionPane.showMessageDialog(null, e);
        }
    }
    
    public final void FilljTxtNomPrenom() throws SQLException {
         //    JTextField field;
    
     affiche("Etape 2");
    String sql1 = "SELECT * FROM Signaletique WHERE Matricule =?";
    ps1 = conn.prepareStatement(sql1);
    ps1.setString(1, jTxtMatr.getText());
    rs1 = ps1.executeQuery();
          System.out.println("Nom");
          System.out.println(jTxtNomPrenom);
    
          ps1.setString(1,jTxtMatr.getText()); // recherche des éléments qui commence par la chaine saisie
              System.out.println(jTxtMatr); 
     try {
         
      //ResultSet rs1 = ps1.executeQuery();
    System.out.println(rs1);
                    while ( rs1.next() ) {
                    // jTxtNomPrenom = (String) rs1.getString(2)+" "+resultats.getString(3); 
                  jTxtNomPrenom.setText(rs1.getString(2)+" "+rs1.getString(3));
     affiche("Etape 3");
    
    System.out.println(rs1.getString(1) +"* \t** "+rs1.getString(2) + rs1.getString(3)+ rs1.getString(4));
            } 
    } 
     catch (SQLException e ) {
         
         e.printStackTrace();
         }
    
             finally {
            if (rs1 != null) { rs1.close(); }
    }
    
    {  
              JOptionPane.showMessageDialog(null, "Saved !!!!!");
              ps1.close();
              conn.close();
    }  
    }
        @SuppressWarnings("unchecked")
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        // Generated using JFormDesigner non-commercial license
        private void initComponents() {
            jLabel1 = new JLabel();
            CmdSave = new JButton();
            jLabel2 = new JLabel();
            TxtDecId = new JTextField();
            jLabel3 = new JLabel();
            jLabel4 = new JLabel();
            TxtNumero = new JTextField();
            jLabel5 = new JLabel();
            jLabel6 = new JLabel();
            jLabel7 = new JLabel();
            jTxtMatr = new JTextField();
            jLabel8 = new JLabel();
            jLabel9 = new JLabel();
            jCheckBoxRefus = new JCheckBox();
            jLabel10 = new JLabel();
            jCheckBox3 = new JCheckBox();
            jCheckBoxPostpose = new JCheckBox();
            jLabel12 = new JLabel();
            jCboPcActivity = new JComboBox<>();
            jCboTypeAbsence = new JComboBox<>();
            jCheckBoxVen1 = new JCheckBox();
            TxtId = new JTextField();
            jDateChooserDateDebut = new JDateChooser();
            jDateChooserDateFin = new JDateChooser();
            jCheckBoxLun1 = new JCheckBox();
            jCheckBoxMar1 = new JCheckBox();
            jCheckBoxMer1 = new JCheckBox();
            jCheckBoxJeu1 = new JCheckBox();
            jCheckBoxVen2 = new JCheckBox();
            jCheckBoxLun2 = new JCheckBox();
            jCheckBoxMar2 = new JCheckBox();
            jCheckBoxMer2 = new JCheckBox();
            jCheckBoxJeu2 = new JCheckBox();
            jScrollPane1 = new JScrollPane();
            jTextAreaRemarques = new JTextArea();
            jLabel11 = new JLabel();
            jCboFiliation = new JComboBox<>();
            jTextNom_Parent = new JTextField();
            jDateChooserDateDec = new JDateChooser();
            jDateChooserPostposeDebut = new JDateChooser();
            jDateChooserPostposeFin = new JDateChooser();
            jTxtNomPrenom = new JTextField();
    
            //======== this ========
            setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            setTitle("A");
            setBackground(new Color(102, 255, 204));
            setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            Container contentPane = getContentPane();
            contentPane.setLayout(null);
    
            //---- jLabel1 ----
            jLabel1.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel1.setText("Id");
            contentPane.add(jLabel1);
            jLabel1.setBounds(24, 42, 28, jLabel1.getPreferredSize().height);
    
            //---- CmdSave ----
            CmdSave.setText("Save record");
            CmdSave.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    CmdSaveMouseClicked(e);
                }
            });
            contentPane.add(CmdSave);
            CmdSave.setBounds(new Rectangle(new Point(400, 430), CmdSave.getPreferredSize()));
    
            //---- jLabel2 ----
            jLabel2.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel2.setText("DecId");
            contentPane.add(jLabel2);
            jLabel2.setBounds(new Rectangle(new Point(24, 68), jLabel2.getPreferredSize()));
            contentPane.add(TxtDecId);
            TxtDecId.setBounds(140, 65, 91, TxtDecId.getPreferredSize().height);
    
            //---- jLabel3 ----
            jLabel3.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel3.setText("Matricule");
            contentPane.add(jLabel3);
            jLabel3.setBounds(24, 94, 47, jLabel3.getPreferredSize().height);
    
            //---- jLabel4 ----
            jLabel4.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel4.setText("Numero");
            contentPane.add(jLabel4);
            jLabel4.setBounds(24, 150, jLabel4.getPreferredSize().width, 18);
            contentPane.add(TxtNumero);
            TxtNumero.setBounds(140, 150, 91, TxtNumero.getPreferredSize().height);
    
            //---- jLabel5 ----
            jLabel5.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel5.setText("Date d\u00e9cision");
            contentPane.add(jLabel5);
            jLabel5.setBounds(new Rectangle(new Point(24, 119), jLabel5.getPreferredSize()));
    
            //---- jLabel6 ----
            jLabel6.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel6.setText("D\u00e9but de l'absence");
            contentPane.add(jLabel6);
            jLabel6.setBounds(20, 240, jLabel6.getPreferredSize().width, 20);
    
            //---- jLabel7 ----
            jLabel7.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel7.setText("Fin de l'absence");
            contentPane.add(jLabel7);
            jLabel7.setBounds(20, 270, 98, 20);
            contentPane.add(jTxtMatr);
            jTxtMatr.setBounds(140, 90, 91, jTxtMatr.getPreferredSize().height);
    
            //---- jLabel8 ----
            jLabel8.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel8.setText("Pc d'activit\u00e9");
            contentPane.add(jLabel8);
            jLabel8.setBounds(18, 180, 110, 20);
    
            //---- jLabel9 ----
            jLabel9.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel9.setText("Type d'absence");
            contentPane.add(jLabel9);
            jLabel9.setBounds(20, 210, jLabel9.getPreferredSize().width, 20);
            contentPane.add(jCheckBoxRefus);
            jCheckBoxRefus.setBounds(new Rectangle(new Point(140, 300), jCheckBoxRefus.getPreferredSize()));
    
            //---- jLabel10 ----
            jLabel10.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel10.setText("Refus");
            contentPane.add(jLabel10);
            jLabel10.setBounds(20, 300, 100, 20);
            contentPane.add(jCheckBox3);
            jCheckBox3.setBounds(new Rectangle(new Point(140, 300), jCheckBox3.getPreferredSize()));
    
            //---- jCheckBoxPostpose ----
            jCheckBoxPostpose.addActionListener(e -> jCheckBoxPostposeActionPerformed(e));
            contentPane.add(jCheckBoxPostpose);
            jCheckBoxPostpose.setBounds(new Rectangle(new Point(140, 330), jCheckBoxPostpose.getPreferredSize()));
    
            //---- jLabel12 ----
            jLabel12.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel12.setText("Pospos\u00e9");
            jLabel12.setRequestFocusEnabled(false);
            contentPane.add(jLabel12);
            jLabel12.setBounds(new Rectangle(new Point(20, 330), jLabel12.getPreferredSize()));
    
            //---- jCboPcActivity ----
            jCboPcActivity.setModel(new DefaultComboBoxModel<>(new String[] {
                "0",
                "10",
                "20",
                "30",
                "40",
                "50",
                "60",
                "70",
                "85",
                "90",
                "100"
            }));
            jCboPcActivity.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            jCboPcActivity.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    jCboPcActivityFocusLost(e);
                }
            });
            contentPane.add(jCboPcActivity);
            jCboPcActivity.setBounds(140, 180, jCboPcActivity.getPreferredSize().width, 20);
    
            //---- jCboTypeAbsence ----
            jCboTypeAbsence.setSelectedIndex(-1);
            contentPane.add(jCboTypeAbsence);
            jCboTypeAbsence.setBounds(140, 210, 180, jCboTypeAbsence.getPreferredSize().height);
    
            //---- jCheckBoxVen1 ----
            jCheckBoxVen1.setText("Vendredi");
            jCheckBoxVen1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxVen1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxVen1);
            jCheckBoxVen1.setBounds(new Rectangle(new Point(390, 320), jCheckBoxVen1.getPreferredSize()));
            contentPane.add(TxtId);
            TxtId.setBounds(140, 40, 90, TxtId.getPreferredSize().height);
    
            //---- jDateChooserDateDebut ----
            jDateChooserDateDebut.setDateFormatString("dd/MM/yyyy");
            jDateChooserDateDebut.setFocusCycleRoot(true);
            jDateChooserDateDebut.setDate(null);
            jDateChooserDateDebut.setBorder(new SoftBevelBorder(SoftBevelBorder.LOWERED));
            contentPane.add(jDateChooserDateDebut);
            jDateChooserDateDebut.setBounds(new Rectangle(new Point(140, 240), jDateChooserDateDebut.getPreferredSize()));
    
            //---- jDateChooserDateFin ----
            jDateChooserDateFin.setDateFormatString("dd/MM/yyyy");
            jDateChooserDateFin.setFocusCycleRoot(true);
            jDateChooserDateFin.setBorder(new BevelBorder(BevelBorder.LOWERED));
            jDateChooserDateFin.setDate(null);
            jDateChooserDateFin.addPropertyChangeListener(e -> jDateChooserDateFinPropertyChange(e));
            contentPane.add(jDateChooserDateFin);
            jDateChooserDateFin.setBounds(new Rectangle(new Point(140, 270), jDateChooserDateFin.getPreferredSize()));
    
            //---- jCheckBoxLun1 ----
            jCheckBoxLun1.setText("Lundi");
            jCheckBoxLun1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxLun1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxLun1);
            jCheckBoxLun1.setBounds(new Rectangle(new Point(390, 240), jCheckBoxLun1.getPreferredSize()));
    
            //---- jCheckBoxMar1 ----
            jCheckBoxMar1.setText("Mardi");
            jCheckBoxMar1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxMar1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxMar1);
            jCheckBoxMar1.setBounds(new Rectangle(new Point(390, 260), jCheckBoxMar1.getPreferredSize()));
    
            //---- jCheckBoxMer1 ----
            jCheckBoxMer1.setText("Mercredi");
            jCheckBoxMer1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxMer1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxMer1);
            jCheckBoxMer1.setBounds(new Rectangle(new Point(390, 280), jCheckBoxMer1.getPreferredSize()));
    
            //---- jCheckBoxJeu1 ----
            jCheckBoxJeu1.setText("Jeudi");
            jCheckBoxJeu1.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxJeu1.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxJeu1);
            jCheckBoxJeu1.setBounds(new Rectangle(new Point(390, 300), jCheckBoxJeu1.getPreferredSize()));
    
            //---- jCheckBoxVen2 ----
            jCheckBoxVen2.setText("Vendredi");
            jCheckBoxVen2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxVen2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxVen2);
            jCheckBoxVen2.setBounds(new Rectangle(new Point(470, 320), jCheckBoxVen2.getPreferredSize()));
    
            //---- jCheckBoxLun2 ----
            jCheckBoxLun2.setText("Lundi");
            jCheckBoxLun2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxLun2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxLun2);
            jCheckBoxLun2.setBounds(new Rectangle(new Point(470, 240), jCheckBoxLun2.getPreferredSize()));
    
            //---- jCheckBoxMar2 ----
            jCheckBoxMar2.setText("Mardi");
            jCheckBoxMar2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxMar2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxMar2);
            jCheckBoxMar2.setBounds(new Rectangle(new Point(470, 260), jCheckBoxMar2.getPreferredSize()));
    
            //---- jCheckBoxMer2 ----
            jCheckBoxMer2.setText("Mercredi");
            jCheckBoxMer2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxMer2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxMer2);
            jCheckBoxMer2.setBounds(new Rectangle(new Point(470, 280), jCheckBoxMer2.getPreferredSize()));
    
            //---- jCheckBoxJeu2 ----
            jCheckBoxJeu2.setText("Jeudi");
            jCheckBoxJeu2.setIcon(new ImageIcon(getClass().getResource("/decisions/Oui.png")));
            jCheckBoxJeu2.setSelectedIcon(new ImageIcon(getClass().getResource("/decisions/Non.png")));
            contentPane.add(jCheckBoxJeu2);
            jCheckBoxJeu2.setBounds(new Rectangle(new Point(470, 300), jCheckBoxJeu2.getPreferredSize()));
    
            //======== jScrollPane1 ========
            {
    
                //---- jTextAreaRemarques ----
                jTextAreaRemarques.setColumns(20);
                jTextAreaRemarques.setFont(new Font("Cambria", Font.PLAIN, 11));
                jTextAreaRemarques.setLineWrap(true);
                jTextAreaRemarques.setRows(5);
                jTextAreaRemarques.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
                jScrollPane1.setViewportView(jTextAreaRemarques);
            }
            contentPane.add(jScrollPane1);
            jScrollPane1.setBounds(new Rectangle(new Point(150, 390), jScrollPane1.getPreferredSize()));
    
            //---- jLabel11 ----
            jLabel11.setFont(new Font("Times New Roman", Font.BOLD, 11));
            jLabel11.setText("Remarques :");
            contentPane.add(jLabel11);
            jLabel11.setBounds(21, 390, 70, jLabel11.getPreferredSize().height);
    
            //---- jCboFiliation ----
            jCboFiliation.setModel(new DefaultComboBoxModel<>(new String[] {
                "<None>",
                "Fils",
                "Fille",
                "P\u00e8re",
                "M\u00e8re",
                "Fr\u00e8re",
                "Soeur",
                "Beau-p\u00e8re",
                "Belle-m\u00e8re"
            }));
            jCboFiliation.addActionListener(e -> jCboFiliationActionPerformed(e));
            contentPane.add(jCboFiliation);
            jCboFiliation.setBounds(330, 210, 100, jCboFiliation.getPreferredSize().height);
            contentPane.add(jTextNom_Parent);
            jTextNom_Parent.setBounds(440, 210, 160, jTextNom_Parent.getPreferredSize().height);
    
            //---- jDateChooserDateDec ----
            jDateChooserDateDec.setDateFormatString("dd/MM/yyyy");
            jDateChooserDateDec.setFocusCycleRoot(true);
            jDateChooserDateDec.setBorder(new BevelBorder(BevelBorder.LOWERED));
            jDateChooserDateDec.setMaxSelectableDate(new java.util.Date(253370764880000L));
            jDateChooserDateDec.setDate(null);
            contentPane.add(jDateChooserDateDec);
            jDateChooserDateDec.setBounds(new Rectangle(new Point(140, 120), jDateChooserDateDec.getPreferredSize()));
    
            //---- jDateChooserPostposeDebut ----
            jDateChooserPostposeDebut.setDateFormatString("dd/MM/yyyy");
            jDateChooserPostposeDebut.setFocusCycleRoot(true);
            jDateChooserPostposeDebut.setBorder(new BevelBorder(BevelBorder.LOWERED));
            jDateChooserPostposeDebut.setDate(null);
            contentPane.add(jDateChooserPostposeDebut);
            jDateChooserPostposeDebut.setBounds(new Rectangle(new Point(165, 330), jDateChooserPostposeDebut.getPreferredSize()));
    
            //---- jDateChooserPostposeFin ----
            jDateChooserPostposeFin.setDateFormatString("dd/MM/yyyy");
            jDateChooserPostposeFin.setFocusCycleRoot(true);
            jDateChooserPostposeFin.setBorder(new BevelBorder(BevelBorder.LOWERED));
            jDateChooserPostposeFin.setDate(null);
            jDateChooserPostposeFin.addPropertyChangeListener(e -> jDateChooserPostposeFinPropertyChange(e));
            contentPane.add(jDateChooserPostposeFin);
            jDateChooserPostposeFin.setBounds(new Rectangle(new Point(275, 330), jDateChooserPostposeFin.getPreferredSize()));
            contentPane.add(jTxtNomPrenom);
            jTxtNomPrenom.setBounds(280, 40, 200, jTxtNomPrenom.getPreferredSize().height);
    
            { // compute preferred size
                Dimension preferredSize = new Dimension();
                for(int i = 0; i < contentPane.getComponentCount(); i++) {
                    Rectangle bounds = contentPane.getComponent(i).getBounds();
                    preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                    preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
                }
                Insets insets = contentPane.getInsets();
                preferredSize.width += insets.right;
                preferredSize.height += insets.bottom;
                contentPane.setMinimumSize(preferredSize);
                contentPane.setPreferredSize(preferredSize);
            }
            pack();
            setLocationRelativeTo(getOwner());
        }// </editor-fold>//GEN-END:initComponents
    
        
        private void CmdSaveMouseClicked(java.awt.event.MouseEvent evt) {
        NullPointerException exp;
                conn = Connect.ConnectDB();
    try{
      
    String sql = "Insert INTO Decisions (Id,DecId,Matr,Datedec,numero,Debut,Fin,Pourcent,AbsType,Refus,Postpose,Post_Debut,Post_Fin,Lu1,Ma1,Me1,Je1,Ve1,Lu2,Ma2,Me2,Je2,Ve2,Remarques,Filiation, Nom_Parent)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
    
    PreparedStatement ps = conn.prepareStatement(sql);
    
    
    ps.setString(1,TxtId.getText()); // à voir si tu dois utiliser ps.setInt()
    
     //TxtDecId - Gestion de valeur Null
     //---------------------------------
     
       if (TxtDecId.getText().equals("")){
         ps.setString(2, "");
        }
         else {
            ps.setString(2, TxtDecId.getText());
        }
       
            ps.setString(3,jTxtMatr.getText());
    
    
    //jDateChooserDateDec- Gestion de valeur Null
    // ==========================================
     
    if ( jDateChooserDateDec.getDate() == null){ 
       ps.setDate(4,null); 
        }  else { 
        ps.setDate(4,new java.sql.Date(jDateChooserDateDec.getDate().getTime()));
        }
    
    ps.setString(5,TxtNumero.getText());
    
    //jDateChooserDateDebut - Gestion de valeur Null
        // ==========================================
     
        if ( jDateChooserDateDebut.getDate() == null){ 
       ps.setDate(6,null); 
        }  else { 
        ps.setDate(6,new java.sql.Date(jDateChooserDateDebut.getDate().getTime()));
        }
    
        //jDateChooserDateDebut - Gestion de valeur Null
        // ==========================================
     
        if ( jDateChooserDateFin.getDate() == null){ 
       ps.setDate(7,null); 
        }  else { 
        ps.setDate(7,new java.sql.Date(jDateChooserDateFin.getDate().getTime()));
        }
        
    ps.setObject(8, jCboPcActivity.getSelectedItem());
    ps.setObject(9,jCboTypeAbsence.getSelectedItem());
    ps.setObject(10, jCheckBoxRefus.isSelected());
    ps.setObject(11, jCheckBoxPostpose.isSelected());
    
     //jDateChooser PostposeDebut - Gestion de valeur Null
     //===================================================
     
    if ( jDateChooserPostposeDebut.getDate() == null){ 
       ps.setDate(12,null); 
        }  else { 
        ps.setDate(12,new java.sql.Date(jDateChooserPostposeDebut.getDate().getTime()));
        }
    // ps.setDate(12,new java.sql.Date(jDateChooserPostposeDebut.getDate().getTime()));
    
     //jDateChooser PostposeDebut - Gestion de valeur Null
     //===================================================
     
    if ( jDateChooserPostposeFin.getDate() == null){ 
       ps.setDate(13,null); 
        }  else { 
        ps.setDate(13,new java.sql.Date(jDateChooserPostposeFin.getDate().getTime()));
        }
    
    //ps.setDate(13,new java.sql.Date(jDateChooserPostposeFin.getDate().getTime()));
    
    ps.setObject(14, jCheckBoxLun1.isSelected());
    ps.setObject(15, jCheckBoxMar1.isSelected());
    ps.setObject(16, jCheckBoxMer1.isSelected());
    ps.setObject(17, jCheckBoxJeu1.isSelected());
    ps.setObject(18, jCheckBoxVen1.isSelected());
    ps.setObject(19, jCheckBoxLun2.isSelected());
    ps.setObject(20, jCheckBoxMar2.isSelected());
    ps.setObject(21, jCheckBoxMer2.isSelected());
    ps.setObject(22, jCheckBoxJeu2.isSelected());
    ps.setObject(23, jCheckBoxVen2.isSelected());
    ps.setString(24, jTextAreaRemarques.getText());
    ps.setObject(25, jCboFiliation.getSelectedItem());
    
    // jTextNom_Parent - Gestion de valeur Null
    // ========================================
            
         if (jTextNom_Parent.getText().equals("")){
          ps.setString(26, "");
        }
        else {
           ps.setString(26, jTextNom_Parent.getText());
       }
    
      //      ps.setString(26, jTextNom_Parent.getText());
     ps.execute();
    
    
              JOptionPane.showMessageDialog(null, "Saved");
                conn.close();
    }
             catch(SQLException | HeadlessException e )
               
    { 
                JOptionPane.showMessageDialog(null, e);
                e.printStackTrace();
            }             
        }
        
    
    /*
        }//GEN-LAST:event_CmdSaveMouseClicked
    */
        private void jCboPcActivityFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jCboPcActivityFocusLost
        NullPointerException exp;
            String x = String.valueOf(jCboPcActivity.getSelectedItem());
            if (x.equals("100")) {
                
              jCheckBoxLun1.setSelected(true);
              jCheckBoxMar1.setSelected(true);
              jCheckBoxMer1.setSelected(true);
              jCheckBoxJeu1.setSelected(true);
              jCheckBoxVen1.setSelected(true);
              jCheckBoxLun2.setSelected(true);
              jCheckBoxMar2.setSelected(true);
              jCheckBoxMer2.setSelected(true);
              jCheckBoxJeu2.setSelected(true);
              jCheckBoxVen2.setSelected(true);
    
            } else {
              jCheckBoxLun1.setSelected(false);
              jCheckBoxMar1.setSelected(false);
              jCheckBoxMer1.setSelected(false);
              jCheckBoxJeu1.setSelected(false);
              jCheckBoxVen1.setSelected(false);
              jCheckBoxLun2.setSelected(false);
              jCheckBoxMar2.setSelected(false);
              jCheckBoxMer2.setSelected(false);
              jCheckBoxJeu2.setSelected(false);
              jCheckBoxVen2.setSelected(false);
              
            }
        //}
    
        }//GEN-LAST:event_jCboPcActivityFocusLost
    
        private void jCheckBoxPostposeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxPostposeActionPerformed
            if (jCheckBoxPostpose.isSelected()){
            jDateChooserPostposeFin.setVisible(true);
            jDateChooserPostposeDebut.setVisible(true);
            }
            else {
            jDateChooserPostposeFin.setVisible(false);
            jDateChooserPostposeDebut.setVisible(false);
            }
        }//GEN-LAST:event_jCheckBoxPostposeActionPerformed
    
    @SuppressWarnings("empty-statement")
       
        private void jCboFiliationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCboFiliationActionPerformed
            
            String y = String.valueOf(jCboFiliation.getSelectedItem());
            
            if (y.equals("<None>")) {
                
              jTextNom_Parent.setVisible(false);
            } else 
            
            {
              jTextNom_Parent.setVisible(true);       
                                    
                      
                    
          }          // TODO add your handling code here:
        }//GEN-LAST:event_jCboFiliationActionPerformed
                            
    
    /**
         * @param args the command line arguments
         */
    
    
        public static void main(String args[]) {
                           
            //java.awt.EventQueue.invokeLater(new Runnable() {
            /* Set the Nimbus look and feel */
            //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
            /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
             * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
             */
            try {
                for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                    if ("Nimbus".equals(info.getName())) {
                        javax.swing.UIManager.setLookAndFeel(info.getClassName());
                        break;
                    }
                }
            } catch (ClassNotFoundException ex) {
                java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
                 ex.printStackTrace();
            } catch (InstantiationException ex) {
                java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
                    ex.printStackTrace();
            } catch (IllegalAccessException ex) {
                java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
                    ex.printStackTrace();
            } catch (javax.swing.UnsupportedLookAndFeelException ex) {
                java.util.logging.Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
                    ex.printStackTrace();
            }
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
            //</editor-fold>
    
            
            /* Create and display the form */
           
            java.awt.EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                    try {
                        new AddDecisionsJFrame1().setVisible(true);
                    } catch (SQLException ex) {
                        Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(Level.SEVERE, null, ex);
                            ex.printStackTrace();
                    }
    
                    
                }
    
                       public void actionPerformed(ActionEvent e) {
                           throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                       }
            });
    }
    
        // Variables declaration - do not modify//GEN-BEGIN:variables
        // Generated using JFormDesigner non-commercial license
        private JLabel jLabel1;
        private JButton CmdSave;
        private JLabel jLabel2;
        private JTextField TxtDecId;
        private JLabel jLabel3;
        private JLabel jLabel4;
        private JTextField TxtNumero;
        private JLabel jLabel5;
        private JLabel jLabel6;
        private JLabel jLabel7;
        private JTextField jTxtMatr;
        private JLabel jLabel8;
        private JLabel jLabel9;
        private JCheckBox jCheckBoxRefus;
        private JLabel jLabel10;
        private JCheckBox jCheckBox3;
        private JCheckBox jCheckBoxPostpose;
        private JLabel jLabel12;
        private JComboBox<String> jCboPcActivity;
        private JComboBox<String> jCboTypeAbsence;
        private JCheckBox jCheckBoxVen1;
        private JTextField TxtId;
        private JDateChooser jDateChooserDateDebut;
        private JDateChooser jDateChooserDateFin;
        private JCheckBox jCheckBoxLun1;
        private JCheckBox jCheckBoxMar1;
        private JCheckBox jCheckBoxMer1;
        private JCheckBox jCheckBoxJeu1;
        private JCheckBox jCheckBoxVen2;
        private JCheckBox jCheckBoxLun2;
        private JCheckBox jCheckBoxMar2;
        private JCheckBox jCheckBoxMer2;
        private JCheckBox jCheckBoxJeu2;
        private JScrollPane jScrollPane1;
        private JTextArea jTextAreaRemarques;
        private JLabel jLabel11;
        private JComboBox<String> jCboFiliation;
        private JTextField jTextNom_Parent;
        private JDateChooser jDateChooserDateDec;
        private JDateChooser jDateChooserPostposeDebut;
        private JDateChooser jDateChooserPostposeFin;
        private JTextField jTxtNomPrenom;
        // End of variables declaration//GEN-END:variables
    
        private void jDateChooserPostposeDebutPropertyChange(PropertyChangeEvent e) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    
       }

  15. #15
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    why line 21 and 23.
    Both those lines are supposed to print to the console, but the copy of the contents that was posted did not show that they had been executed to print in the console.
    Why wasn't there any output on the console from those two statements?
    If you don't understand my response, don't ignore it, ask a question.

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: JtextField and Table MS Access value.

    (For some reason this one didn't manage to get posted)

    This code is different to the one you posted above.
    I've formatted the code...you really need to learn to format your code properly.
    Java Code:
        public final void FilljTxtNomPrenom() throws SQLException {
            affiche("Etape 2");
            String sql1 = "SELECT * FROM Signaletique WHERE Matricule =?";
            ps1 = conn.prepareStatement(sql1);
            ps1.setString(1, jTxtMatr.getText());
            rs1 = ps1.executeQuery();
            System.out.println("Nom");
            System.out.println(jTxtNomPrenom);
    
            ps1.setString(1,jTxtMatr.getText()); // recherche des éléments qui commence par la chaine saisie
            System.out.println(jTxtMatr);
            try {
                System.out.println(rs1);
                while ( rs1.next() ) {
                    jTxtNomPrenom.setText(rs1.getString(2)+" "+rs1.getString(3));
                    affiche("Etape 3");
    
                    System.out.println(rs1.getString(1) +"* \t** "+rs1.getString(2) + rs1.getString(3)+ rs1.getString(4));
                }
            } catch (SQLException e ) {
                e.printStackTrace();
            } finally {
                if (rs1 != null) { rs1.close(); }
            }
    
            {
                JOptionPane.showMessageDialog(null, "Saved !!!!!");
                ps1.close();
                conn.close();
            }
        }
    So.
    What happens when you run this code?
    What output do your get?

    Why are you doing this?
    Java Code:
    ps1.setString(1,jTxtMatr.getText());
    after you've already executed the query?
    It achieves nothing, so throw that line out.

    This println:
    Java Code:
    System.out.println(jTxtMatr);
    should be printing the text value, not the field state.
    Once you have that value then you can look into running the same query on your database and see if you get any results.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  17. #17
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    Now Í' ve a problem with the sql exception. By the frame definition i think.
    But I use jFrormDesigner
    How can I store the value of Matricule (Access) into de jTxtMatr

    Habiler

    Java Code:
    tion in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - unreported exception java.sql.SQLException; must be caught or declared to be thrown
    	at decisions.AddDecisionsJFrame1$3.mouseClicked(AddDecisionsJFrame1.java:235)
    	at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
    	at java.awt.Component.processMouseEvent(Component.java:6536)
    	at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    	at java.awt.Component.processEvent(Component.java:6298)
    	at java.awt.Container.processEvent(Container.java:2236)
    	at java.awt.Component.dispatchEventImpl(Component.java:4889)
    	at java.awt.Container.dispatchEventImpl(Container.java:2294)
    	at java.awt.Component.dispatchEvent(Component.java:4711)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
    	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4534)
    	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
    	at java.awt.Container.dispatchEventImpl(Container.java:2280)
    	at java.awt.Window.dispatchEventImpl(Window.java:2746)
    	at java.awt.Component.dispatchEvent(Component.java:4711)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    	at java.awt.EventQueue$4.run(EventQueue.java:731)
    	at java.awt.EventQueue$4.run(EventQueue.java:729)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

  18. #18
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    tion in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - unreported exception java.sql.SQLException; must be caught or declared to be thrown
    That is a compiler error that says the code must catch java.sql.SQLException. Can you compile (not run) the source to get a good compiler error that shows where the error is?
    If you don't understand my response, don't ignore it, ask a question.

  19. #19
    habiler is offline Member
    Join Date
    Sep 2016
    Posts
    44
    Rep Power
    0

    Default Re: JtextField and Table MS Access value.

    So i said I use jFormDesigner and I can access to this part of code

    Java Code:
     //---- CmdSave ----
            CmdSave.setText("Save record");
            CmdSave.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    CmdSaveMouseClicked(e);
                }
            });
            contentPane.add(CmdSave);
            CmdSave.setBounds(new Rectangle(new Point(400, 430), CmdSave.getPreferredSize()));
    Java Code:
    C:\Users\habiler\Desktop\decisions_T1\src\AncestorTest.java:61: warning: [deprecation] show() in Window has been deprecated
        frame.show();
    C:\Users\habiler\Desktop\decisions_T1\src\decisions\AddDecisionsJFrame1.java:236: error: unreported exception SQLException; must be caught or declared to be thrown
                    CmdSaveMouseClicked(e);
    1 error
    1 warning
    C:\Users\habiler\Desktop\decisions_T1\nbproject\build-impl.xml:955: The following error occurred while executing this line:
    C:\Users\habiler\Desktop\decisions_T1\nbproject\build-impl.xml:295: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 2 seconds)

  20. #20
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,997
    Rep Power
    32

    Default Re: JtextField and Table MS Access value.

    :\Users\habiler\Desktop\decisions_T1\src\decisions \AddDecisionsJFrame1.java:236: error: unreported exception SQLException; must be caught or declared to be thrown
    CmdSaveMouseClicked(e);
    Is there a statement in that method that can throw SQLException? It should be handled with a try{} catch. A mouseClick listener can't throw it.
    If you don't understand my response, don't ignore it, ask a question.

Page 1 of 2 12 LastLast

Similar Threads

  1. Jcombobox et table access
    By habiler in forum NetBeans
    Replies: 4
    Last Post: 10-28-2016, 09:21 AM
  2. Replies: 2
    Last Post: 04-03-2013, 04:33 PM
  3. how can i update my table with Jtextfield filtering?
    By sungirl in forum Advanced Java
    Replies: 4
    Last Post: 12-14-2010, 04:28 PM
  4. Replies: 1
    Last Post: 01-30-2009, 06:44 PM
  5. Replies: 2
    Last Post: 07-30-2008, 12:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •