Please how can i insert into two different tables in mysql using java. i tried this and its only for one table. so how can i insert into branches and items table simultaneously in the same code?
try{
String sql = "Insert into asset_update (Date_Acquired,Item_Code,Serial_Number,Cost_Of_Acquisition,Estimated_Useful_Life,Depreciation_Start_Date,User,Status,Disposal_Date)values (?,?,?,?,?,?,?,?,?)";
pst=conn.prepareStatement(sql);
pst.setString(1, ((JTextField)date_aquired.getDateEditor().getUiComponent()).getText());
String ItemCode = ComboBox_itemCode.getSelectedItem().toString();
pst.setString(2, ItemCode );
pst.setString(3, txt_sn.getText());
pst.setString(4, txt_coa.getText());
pst.setString(5, eul.getText());
pst.setString(6, ((JTextField)date_dsd.getDateEditor().getUiComponent()).getText());
String users = jComboBox_Users.getSelectedItem().toString();
pst.setString(7, users);
String status = ComboBox_status.getSelectedItem().toString();
pst.setString(8, status);
pst.setString(9, ((JTextField)date_dd.getDateEditor().getUiComponent()).getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Saved");
}
catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}
}