Why do I always get the error Student_Id do not have a default value?
Is there something some with my code?
Cant I do 2 PreparedStement and execute it together?
private void cmdaddMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cmdaddMouseClicked
// TODO add your handling code here:
//String sql = "INSERT INTO student (Student_ID, Last_Name, First_Name, Middle_Initial, Address, Course, Year, Contact_No, Equipment_Name, Quantity, Date_Borrowed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
String sql = "INSERT INTO student (Student_ID, Last_Name, First_Name, Middle_Initial, Address, Course, Year, Contact_No, Date_Borrowed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
String sql2 = "INSERT INTO equipment (Equipment_Name, Quantity) VALUES (?, ?)";
try{
pst = conn.prepareStatement(sql);
pst.setString(1, txtid.getText());
pst.setString(2, txtlast.getText());
pst.setString(3, txtfirst.getText());
pst.setString(4, txtinitial.getText());
pst.setString(5, txtaddress.getText());
pst.setObject(6, itemcourse.getSelectedItem());
pst.setObject(7, itemyear.getSelectedItem());
pst.setString(8, txtcontact.getText());
pst.setObject(9, jDateChooser1.getDate());
pst.execute();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
e.printStackTrace();
}
try{
pst2 = conn.prepareStatement(sql2);
pst2.setObject(1, comboequip.getSelectedItem());
pst2.setObject(2, itemquantity.getSelectedItem());
pst2.execute();
}
catch(Exception e){
JOptionPane.showMessageDialog(null, e);
e.printStackTrace();
}
}