Good evening, I try to insert values in the database but the jspinner ones caused a problem for the success of my request.
Please help me.
this is my code :
String sql=" insert into produit(reference , designation , uniteMesure , code, stock , prixUnitaireHTaxe , desg_fam , code_fournisseur) values(? , ? , ? , ? , ? , ? , ? , ? ) ";
try {
prepared=cnx.prepareStatement(sql);
prepared.setString(1,txtRef.getText().toString());
prepared.setString(2,txtDesg.getText().toString());
prepared.setString(3,comboBox.getSelectedItem().toString());
prepared.setString(4,jspinner.getSelectedItem().toString());
//prepared.setString(5,txtMin.getS.toString());
prepared.setString(6,txtPrix.getText().toString());
prepared.setString(7,txtDesign.getText().toString());
prepared.setString(8,txtCode.getText().toString());
prepared.setString(9,txtFour.getText().toString());
JOptionPane.showMessageDialog(null,"Produit ajouté :D");
}
catch(SQLException e1) {
e1.printStackTrace();
}
```
question from:
https://stackoverflow.com/questions/65911234/how-can-i-insert-a-jspinner-integer-value-in-mysql-database-using-java 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…