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

    Default Re: JtextField and Table MS Access value.

    So I ve modified the code also :

    Java Code:
            try {
                ps.close();
            } catch (SQLException ex) {
                Logger.getLogger(AddDecisionsJFrame1.class.getName()).log(Level.SEVERE, null, ex);
            }
    And it shows me only a wrning error :

    But the name of my customer don t appears into my jTextField jTxtNomPrenom

    Habiler
    Java Code:
    ant -f C:\\Users\\habiler\\Desktop\\decisions_T1 -Dnb.internal.action.name=rebuild clean jar
    init:
    deps-clean:
    Updating property file: C:\Users\habiler\Desktop\decisions_T1\build\built-clean.properties
    Deleting directory C:\Users\habiler\Desktop\decisions_T1\build
    clean:
    init:
    deps-jar:
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build
    Updating property file: C:\Users\habiler\Desktop\decisions_T1\build\built-jar.properties
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\classes
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\empty
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\generated-sources\ap-source-output
    Compiling 14 source files to C:\Users\habiler\Desktop\decisions_T1\build\classes
    C:\Users\habiler\Desktop\decisions_T1\src\AncestorTest.java:61: warning: [deprecation] show() in Window has been deprecated
        frame.show();
    1 warning
    Copying 6 files to C:\Users\habiler\Desktop\decisions_T1\build\classes
    compile:
    Created dir: C:\Users\habiler\Desktop\decisions_T1\dist
    Copying 1 file to C:\Users\habiler\Desktop\decisions_T1\build
    Copy libraries to C:\Users\habiler\Desktop\decisions_T1\dist\lib.
    Building jar: C:\Users\habiler\Desktop\decisions_T1\dist\decisions_T1.jar
    To run this application from the command line without Ant, try:
    java -jar "C:\Users\habiler\Desktop\decisions_T1\dist\decisions_T1.jar"
    jar:
    BUILD SUCCESSFUL (total time: 3 seconds)

  2. #22
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    name of my customer don t appears
    Is there an error?
    What message is logged by the statement on line 4?

    It's helpful if there is also a call to the printStackTrace method in the catch block so the full trace of the error is shown.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    So the code now builds correctly?
    That was the issue before, with the compilation.

    You need to stick some logging in the code so you can see what values are being passed around.
    If that field is supposed to be populated from the database then add debugging into the database code to note whether and what value is retrieved.
    That way you can narrow down where the issue is.

    Quote Originally Posted by Norm View Post
    It's helpful if there is also a call to the printStackTrace method in the catch block so the full trace of the error is shown.
    That Logger should log the exception in full, with the stack trace.
    SO long as the logging system has been set up correctly, of course.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

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

    Default Re: JtextField and Table MS Access value.

    Now a I ve an error at line 1047 in fact line 1010.

    Java Code:
        // Variables declaration - do not modify//GEN-BEGIN:variables
        // Generated using JFormDesigner non-commercial license
       
    ..........
    ...........
        private JTextArea jTextAreaRemarques;
        private JLabel jLabel11;
        private JComboBox<String> jCboFiliation;
        private JTextField jTextNom_Parent;
        private JDateChooser jDateChooserDateDec;
        private JDateChooser jDateChooserPostposeDebut;
        private JDateChooser jDateChooserPostposeFin;
       [COLOR="#0000FF"] private JTextField jTxtNomPrenom;[/COLOR]
        // End of variables declaration//GEN-END:variables
    Java Code:
    Deleting directory C:\Users\habiler\Desktop\decisions_T1\build
    clean:
    init:
    deps-jar:
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build
    Updating property file: C:\Users\habiler\Desktop\decisions_T1\build\built-jar.properties
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\classes
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\empty
    Created dir: C:\Users\habiler\Desktop\decisions_T1\build\generated-sources\ap-source-output
    Compiling 12 source files to C:\Users\habiler\Desktop\decisions_T1\build\classes
    [COLOR="#0000FF"]C:\Users\habiler\Desktop\decisions_T1\src\decisions\AddDecisionsJFrame11.java:1047: error: reached end of file while parsing
        private JTextField jTxtNomPrenom;[/COLOR]
    1 error
    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: 1 second)

  5. #25
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    error: reached end of file while parsing
    Make sure there is a } for every {
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    I ve repared the error with } and no I haven't a compiling error but no name et firstname appears into jtxtNomPrenom well as I replace the ? of my SQL code by A number corresponding to a customer it s running OK.

    Sorry,

    Habiler

    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());// recherche des éléments qui commence par la chaine saisie   
            rs1 = ps1.executeQuery();
            System.out.println( jTxtMatr);
            System.out.println(jTxtNomPrenom            
                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();
            }
        }
    Last edited by habiler; 11-11-2016 at 01:35 AM.

  7. #27
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    I haven't a compiling error
    Are you sure? Look at the end of line 9.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    And once that's fixed I will (again) suggest that you put some debugging log statements in that method to check exactly what value is being pulled from the text field.
    You continue to print the text field object and not the text value.

    And why have you stopped using a logger?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

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

    Default Re: JtextField and Table MS Access value.

    Hello
    I m a beginner in Java and it s poor.
    Could you show me how I can see the value of the field I thought that the value name of my acces Db would appears into jTxtNomPrenom>


    Sorry

    Habiler

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

    Default Re: JtextField and Table MS Access value.

    Java Code:
            System.out.println( jTxtMatr);
            System.out.println(jTxtNomPrenom);
    Those two are JTextFields.
    You want to check the text value in those fields, so you should be printing using getText() (as you have done with the setString() method on the statement) to see the actual value you are passing into the SQL.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

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

    Default Re: JtextField and Table MS Access value.

    Thanks for all.

    I ve the value of jTxtMatr and JtxtNomPrenom. they are null.
    But when I replace ? by a number of customer they are OK. (jTxtMatr and JtxtNomPrenom)

    Habiler

  12. #32
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    the value of jTxtMatr and JtxtNomPrenom. they are null.
    That means those variables have not been assigned values.
    Or do you mean that those text fields are empty? There is a difference.

    when I replace ? by a number of customer they are OK.
    That does not make sense. Changing the contents of a SQL statement would not assign values to Swing component variables.
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    Where can I assign a value or parameter for finding a data from the DB. I will change the ? by a + JtxtMatr.getText(); ??

    System.out.println(jTxtMatr.getText("Matr")); gives my an error because no value in Matr

    Java Code:
    public final void FilljTxtNomPrenom() throws SQLException {
             System.out.println(jTxtMatr.getText("Matr"));
            if ( !jTxtMatr.getText().matches("\\d+") ) return;
            affiche("Etape 2");
            String sql1 = "SELECT * FROM Signaletique WHERE Matricule = ?";
            ps1 = conn.prepareStatement(sql1);
            ps1.setLong(1, Long.parseLong(jTxtMatr.getText()));
            rs1 = ps1.executeQuery();
            System.out.println(jTxtMatr.getText(Matr));
            //System.out.println("Nom");
            //System.out.println(jTxtNomPrenom);
            //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();
                }
            }

  14. #34
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    gives my an error
    Please copy the full text of the error message and paste it here. It has important info about the error.

    What class is jTxtMatr? Does its get() method take an argument?
    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    Hello.

    Now i ve no more error nsg but the Name doesn t appears into jTxtNomPrenom.

    Where is the variable jTxtMatr (it s a field on my screen) to be declared?

    Please

    Java Code:
    public final void FilljTxtNomPrenom() throws SQLException {
       //      System.out.println(jTxtMatr.getText(TextMatr));
            if ( !jTxtMatr.getText().matches("\\d+") ) return;
            affiche("Etape 2");
            String sql1 = "SELECT * FROM Signaletique WHERE Matr = ?";
            ps1 = conn.prepareStatement(sql1);
            ps1.setLong(1, Long.parseLong(jTxtMatr.getText()));
            rs1 = ps1.executeQuery();
            System.out.println(jTxtMatr.getText());
    
            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();
            }
        }
    Last edited by habiler; 11-15-2016 at 05:17 PM.

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

    Default Re: JtextField and Table MS Access value.

    Hello,[

    I rewritted my code again.
    Java Code:
    private void FilljTxtNomPrenom() {
        
            try {
    
                affiche("Etape 2");
    Line 135 ==> PreparedStatement rechercheMatr = conn.prepareStatement ("SELECT * FROM Signaletique WHERE Matr =?");
              rechercheMatr.setString(1, "Matr");
                
                rechercheMatr.setString(4, jTxtNomPrenom.getText());
                //jTxtNomPrenom.setString(rechercheMatr.getText(4));
                rechercheMatr.executeQuery();
                affiche("Etape 2.1");
    
            } catch (SQLException ex) {
                Logger.getLogger(AddDecisionsJFrame11.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    When I compile it he gives my no error but by executing of thiem I receive following error :

    Java Code:
    at net.ucanaccess.jdbc.UcanaccessConnection.prepareStatement(UcanaccessConnection.java:528)
    	at decisions.AddDecisionsJFrame11.FilljTxtNomPrenom(AddDecisionsJFrame11.java:135)
    	at decisions.AddDecisionsJFrame11.<init>(AddDecisionsJFrame11.java:41)
    	at decisions.Jlogin.jButton1MouseClicked(Jlogin.java:110)
    	at decisions.Jlogin.access$100(Jlogin.java:15)
    	at decisions.Jlogin$2.mouseClicked(Jlogin.java:52)
    	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)
    Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MATR
    	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    	at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
    	at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source)
    	at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source)
    	at net.ucanaccess.jdbc.UcanaccessConnection.prepareStatement(UcanaccessConnection.java:525)
    	... 37 more
    Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: MATR
    	at org.hsqldb.error.Error.error(Unknown Source)
    	at org.hsqldb.error.Error.error(Unknown Source)
    	at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
    	at org.hsqldb.QueryExpression.resolve(Unknown Source)
    	at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
    	at org.hsqldb.ParserCommand.compilePart(Unknown Source)
    	at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
    	at org.hsqldb.Session.compileStatement(Unknown Source)
    	at org.hsqldb.StatementManager.compile(Unknown Source)
    	at org.hsqldb.Session.execute(Unknown Source)
    	... 40 more

  17. #37
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,966
    Rep Power
    31

    Default Re: JtextField and Table MS Access value.

    If you don't understand my response, don't ignore it, ask a question.

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

    Default Re: JtextField and Table MS Access value.

    You need to test your queries in the database itself, using the account you are logging in as.

    So, does that query work?

    And as mentioned on that other forum, there's no point in line 9. To be honest, I'm surprised it doesn't throw an exception.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Page 2 of 2 FirstFirst 12

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
  •