title: Violation on Foreign Key
body: <p>Hi I am a beginner in java db netbeans.,</p>
  
  <p>I have two tables namely transaction and checks tables
  in transaction table I have columns named [transID], [PayToOrder], [BankCode], [Checknumber].
  in checks table I have columns named [checknumber], [dateissued], [amount], [transID].
  I am using a form as an entry. </p>
  
  <p>here is the block of code that I used to insert data in the database.</p>
  
  <pre><code>private void btnAddRecordActionPerformed(java.awt.event.ActionEvent evt) {                                             
      // TODO add your handling code here:
      String trID = txtTransID.getText();
      int ID = Integer.parseInt(trID);
      String pto = txtPtO.getText();
      String bc = txtBankCode.getText();
      String cn = txtCheckNum.getText();
      int chNum = Integer.parseInt(cn);
      String amount = txtAmount.getText();
      int amnt = Integer.parseInt(amount);
      String dates = (String) txtDate.getValue();
  
      try{
          stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
          stmt2 = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
          String sql1 = "Select * From transactions";
          String sql2 = "Select * From checks";
          rs1 = stmt1.executeQuery(sql1);
          rs2 = stmt2.executeQuery(sql2);
  
          rs1.moveToInsertRow();
          rs2.moveToInsertRow();
  
          rs1.updateInt("transID", ID);
          rs1.updateString("PAYTOORDER", pto);
          rs1.updateString("BANKCODE", bc);
          rs1.updateInt("checknumber", chNum);
          rs2.updateInt("checknumber", chNum);
          rs2.updateInt("AMOUNT", amnt);
          rs2.updateString("DATEISSUED", dates);
          rs2.updateInt("transID", ID);
  
          rs1.insertRow();
          rs2.insertRow();
          stmt1.close();
          stmt2.close();
          rs1.close();
          rs2.close();
  
          JOptionPane.showMessageDialog(this, "Successfully Recorded!");
         }
  
      catch(SQLException err){
          JOptionPane.showMessageDialog(this, err.getMessage());
      }
  }
  </code></pre>
  
  <p>I keep on getting a error:</p>
  
  <p>"Insert on table 'TRANSACTIONS' caused a violation of Foreign Key constraint 'CHECKNUMBER' for key (inputted data).</p>
  
  <p>please if anyone can enlighten me on this part</p>
  
  <p>thanks </p>
  
  <p>Rommel Ando </p>