Cant input data into my database

hi am trying to insert data into a junction table in my database. the junction table is Services_Transactions connected to three tables...services,staff and customers... i have enforced referential integrity in the services,staff and customers tables but when i run the code and try to insert data into the JFrame form i get the Error:

"
Error in Connection3java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] You cannot add or change a record because a related record is required in table 'Customers'. "

but when i remove the referential integrity the insertion of data is ok. how can i solve this problem?

Comments

  • Re: Cant input data into my Access database

    this is the insertion code
    try{
                pst=conx1.prepareStatement(sqlinsert);
                pst.execute();
                
                try{
            int servicescost,balance,pay;
            String payz=txtpay.getText();
            pay=Integer.parseInt(payz);
            String cost=servicesCost.getText();
    
            servicescost=Integer.parseInt(cost);
    
            balance=pay-servicescost;
            if(pay>servicescost||pay==servicescost){
            JOptionPane.showMessageDialog(null,"The customers change is "+balance);
            JOptionPane.showMessageDialog(null,"Saved Details");}
    catch(Exception wwi){
                    JOptionPane.showMessageDialog(null,"Error in Connection2"+wwi);
                }
            }
      
                catch(Exception c){
                    System.out.println("Error in Connection3"+c);
                }
    
    
Sign In or Register to comment.