I'm trying to insert date to mysql database from data-picker using javaFx. I am tired by submit this code.
@FXML
private DatePicker DPCurrentDate;//fx:id="DPCurrentDate"
// BrandAdded is a Method that i created for insert data into database
private void BrandAdded(){
DBConnection newCon = new DBConnection();
con = newCon.geConnection();
try {
pst = con.prepareStatement("insert into Brands values(?,?,?,?,?)");
pst.setString(1, null);
pst.setString(2, TFBrandName.getText());
pst.setString(3, TABrandDecription.getText());
pst.setString(4, lblUserName.getText());
pst.setDate(5, DPCurrentDate.getValue());
pst.executeUpdate();
} catch (SQLException ex) {
Logger.getLogger(AddBrandController.class.getName()).log(Level.SEVERE, null, ex);
}
}
when i run my program it give me this error
error: incompatible types: LocalDate cannot be converted to Date
pst.setDate(5, DPCurrentDate.getValue());