Ojas Kale
Ojas Kale

Reputation: 2159

Insert button connectivity

I am developing a java program, backend : MS Access . I have written the code there no error or Exception, all other buttons are working fine .

Only the button "insert" (used for inserting into database from GUI) is not working .. no error is shown by net beans .

         b1.addActionListener(new ActionListener(){
            @Override
            public void actionPerformed (ActionEvent e)
            {
                String fname=t1.getText();
                String lname=t2.getText();
                String age=t3.getText();

                try{
                    rs.moveToInsertRow();//moves cursor to new row

                    rs.updateString("Fname", fname);
                    rs.updateString("Lname", lname);
                    rs.updateString("age", age);
                    rs.insertRow();

                    //close two variable
                    st.close();
                    rs.close();
                catch(Exception ex){

                }

            }
        });

Upvotes: 0

Views: 91

Answers (1)

Joseph Selvaraj
Joseph Selvaraj

Reputation: 2237

Follow these steps:

  1. Add ex.printStackTrace(); in your catch block.

                    //close two variable
                    st.close();
                    rs.close();
                catch(Exception ex){
                      ex.printStackTrace();
    
                }
    
  2. Run you application and try to insert a record

  3. This will throw the error message and because of this new code it will display the complete exception stack trace in your console or log.

You may able to find the problem from the error message. If not paste the error message to the community for further help.

Upvotes: 1

Related Questions