1 Reply Latest reply: Nov 9, 2013 11:48 AM by jschellSomeoneStoleMyAlias RSS

    Getting a Runtime Exception while inserting value in MSAccess 2000

    9e40c49a-adc4-411d-8bbd-8c8bf63ea532

      I am using below mentioned code to insert values in MSAccess 2000 which having table structure as mentioned below:-

       

      Field NameData Type
      TodaysDateDate/Time
      Cart IDNumber
      Client NameText
      Team & SegmentText
      DurationNumber
      Tape IDText
      Start DateDate/Time
      End DateDate/Time

       

       

      Code:-

       

      private boolean enterDataIntoMSAccessDatabaseusingPreparedStatement()

          {

              try {

                

                  ps = connection.prepareStatement("INSERT INTO [Cart ID Details] VALUES (?,?,?,?,?,?,?,?)");

                

                  System.out.println("After Query");

                

              }

            

              catch (SQLException se) {

                

                  generateErrorMessage("Error in Prepared Statement \n " + se.getMessage() );

                

                  return false;

                

              }

            

              catch (Exception e)

              {

                  generateErrorMessage("Unexpected Error Occured \n " + e.getMessage());

              }

            

              String todaysDate = cartIDApplicationAddCartIDDatejTextField.getText().trim();

            

              String cartID = cartIDApplicationAddCartIDCartIDjTextField.getText().trim();

            

              String clientName = cartIDApplicationAddCartIDClientNamejTextField.getText().trim();

            

              String teamSegment = cartIDApplicationAddCartIDTeamAndSegmentjTextField.getText().trim();

            

              String duration = cartIDApplicationAddCartIDDurationjTextField.getText().trim();

            

              String tapeID = cartIDApplicationAddCartIDTapeIDjTextField.getText().trim();

            

              String startDate = cartIDApplicationAddCartIDStartDatejTextField.getText().trim();

            

              String endDate = cartIDApplicationAddCartIDEndDatejTextField.getText().trim();

            

              try {

            

                  //System.out.println("Before ps.setString()");

                

                  ps.setString(1, todaysDate);

                  ps.setString(2, cartID );

                  ps.setString(3, clientName);

                  ps.setString(4, teamSegment);

                  ps.setString(5, duration);

                  ps.setString(6, tapeID);

                  ps.setString(7, startDate);

                  ps.setString(8, endDate);

       

       

                  //System.out.println("After ps.setString()");

              

                      ps.executeUpdate();

               

                

             }

              catch (SQLException se) {

                

                  generateErrorMessage("Error while inserting data in database \n " + se.getMessage());

                

                  return false;

              }

            

              catch (Exception e)

              {

                  generateErrorMessage("Unexpected Error Occured \n" + e.getMessage() );

              }

            

              return true;

          }   

       

      The above boolean function is called in "Save Button" action event, but when I click Save I am getting as Runtime Exception.

       

      Kindly help me to sort out this issue.