I have an SQL query that brings two (2) data that are name and licenseexpires
SELECT nombre, licenciaexpira FROM conductores
I have managed to show the name on my Table but the date does not. I was investigating and I realized that my license data expires in mysql is of type "Date" but I can not understand how to show it since I change the data type in the code but it shows me Error.
here the code:
public class Panel2{
private StringProperty Nombre;
private StringProperty FechaVence;
public Panel2(String Nombre, String FechaVence) {
this.Nombre = new SimpleStringProperty(Nombre);
this.FechaVence = new SimpleStringProperty(FechaVence);
}
//Metodos atributo: Nombre
public String getNombre() {
return Nombre.get();
}
public void setNombre(String Nombre) {
this.Nombre = new SimpleStringProperty(Nombre);
}
public StringProperty NombreProperty() {
return Nombre;
}
//Metodos atributo: FechaVence
public String getFechaVence() {
return FechaVence.get();
}
public void setFechaVence(String FechaVence) {
this.FechaVence = new SimpleStringProperty(FechaVence);
}
public StringProperty FechaVenceProperty() {
return FechaVence;
}
//
public static void mostrarFechaLicenciasVence(Connection connection, ObservableList<Panel2> infofechasvence) {
try {
Statement instruccion = connection.createStatement();
ResultSet resultado = instruccion.executeQuery("SELECT nombre, licenciaexpira FROM conductores");
while (resultado.next()) {
infofechasvence.add(
new Panel2(
resultado.getString("nombre"),
resultado.getString("licenciaexpira")
)
);
}
} catch (SQLException e) {
}
}
}
Here the Controller:
infofechasvence = FXCollections.observableArrayList();
Panel2.mostrarFechaLicenciasVence(conexion.getConnection(), infofechasvence);
tbl_fechasexpiralic.setItems(infofechasvence);
clmnnombre.setCellValueFactory(
new PropertyValueFactory<Panel2, String>("nombre")
);
clmnfechaexpira.setCellValueFactory(
new PropertyValueFactory<Panel2, String>("licenciaexpira")
);
The table looks like this: