下面的这段代码我要从jframe保存数据,但是当我从中选择项目时 jComboBox它采用了其他项,这是因为我将索引保存到表中,但在jcombobox中显示了课程名称
String insert = "exec insertstudcourse ?,?,?,?";
try {
pst = con.prepareStatement(insert);
pst.setInt(1, Integer.parseInt(jTextField2.getText()));
pst.setInt(2, jComboBox1.getSelectedIndex()+1);
pst.setString(3, jDateChooser1.getDate().toLocaleString());
pst.setString(4, jTextField1.getText());
pst.execute();
JOptionPane.showMessageDialog(null, "Student info saved");
Table_Data();
clear();
} catch (HeadlessException | SQLException ex) {
JOptionPane.showMessageDialog(null, ex);
}