我真的不知道问题出在哪里。 我的变数:
String notes = hNotes.getText();
Double resTot = Double.parseDouble(hRes.getText());
Double reakTot = Double.parseDouble(hReak.getText());
这里是buttonActions:
try {
String que = "insert into result(notes,resistance,reactant) values(?,?,?)";
PreparedStatement ps = c.prepareStatement(que, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, notes);
ps.setDouble(2, resTot);
ps.setDouble(3, reakTot);
ps.executeUpdate(); //this code is failed to execute
ps.close();
JOptionPane.showMessageDialog(this,"Success..!!","Info Message",1);
} catch (SQLException e){
JOptionPane.showMessageDialog(this,"Failed..!!","Error Message",0);
} finally{
loadData();
}
当我按下按钮时,它总是给我失败的结果。 这是我的表结构:
id, int(11) --> autoincrement
notes, varchar(20), not null
resistance, double, not null
reactant, double, not null