I don't know why I am having null
despite comparing the code to the ones I've written before.
This is my Java code to insert data into table:
@FXML
private void rewards_Parameters(){
try{
String sql = "INSERT INTO SetUpReward VALUES(?,?,?,?,?,?)";
if(sql !=null){
pst =con.prepareStatement(sql);
pst.setString(2, txt_minGiftValue.getText());
pst.setString(3, txt_maxGiftValue.getText());
pst.setString(4, txt_RewardPoint.getText());
pst.execute();
}
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e);
}
}
My Init process...
/**
* FXML Controller class
*
* @author JIDO
*/
public class IGisftCardController implements Initializable {
Connection con =null;
ResultSet rs = null;
PreparedStatement pst ;
Stacktrace:
Caused by:
java.lang.NullPointerException
at view_controller.IGisftCardController.loadReward(IGisftCardController.java:249)
at view_controller.IGisftCardController.initialize(IGisftCardController.java:168)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
... 22 more
Exception running application igiftcardfx.IGiftCardFX
Java Result: 1